home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update21.zoo / lib / diffc < prev    next >
Encoding:
Text File  |  1992-06-03  |  88.9 KB  |  3,926 lines

  1. *** 1.74    1992/04/19 16:02:45
  2. --- Changelo    1992/06/03 14:47:44
  3. ***************
  4. *** 3067,3069 ****
  5. --- 3067,3171 ----
  6.       find stuff in such PATH's (like when using findfile).
  7.   
  8.   ---------------------------- Patchlevel 80 ---------------------------
  9. + bcopy.s:: michal
  10. +     I looked at this new bcopy from the latest update and decided to check
  11. +     if it is faster only theoretically or maybe also in practice.  Reason
  12. +     beeing that my friend claimed that he tried a similar code on TT and
  13. +     after much coding it was actually slower.  So I got curious.  Well, at
  14. +     least on my Mega it is faster.  For some cases significantly so.
  15. +     Although nearly twice as big as the previous one.  Still I found that
  16. +     a small change speeds it up BUT in my experiments only for misaligned
  17. +     data.  In such situations I got up to 10% shorter times for a little
  18. +     bit longer data (break-even seems to be around 25 bytes; for
  19. +     smaller sizes the modified code is a tad slower but differences in timing
  20. +     are truly neglibible).  I still wonder why a similar change in a loop
  21. +     control for aligned data did not bring any real speed variations.
  22. +     
  23. +     Another surprise - two tests with branches for the last three
  24. +     bytes are actually better than a tight dbra loop.  This may look
  25. +     quite a bit different on a small instruction cache of 68020.
  26. +     [ jrb: yes, also it will be interesting to see the difference on
  27. +     68k's with loop-mode (is the 010 the only one??)].
  28. + localtim.c:: ++jrb
  29. +     rename dst to _dst and make it non-static. timeoday.c uses it.
  30. + ctype.c:: ++jrb
  31. +     break out toupper(), tolower() into seperate file so that
  32. +     users can re-define these and yet pull in ctype stuff, whout
  33. +     clashing.  (me2 does this).
  34. + toxxx.c:: +=jrb
  35. +     new file comtaining toupper()/tolower()
  36. + mincl:: ++jrb
  37. +     add target for toxxx.o
  38. + mintbind.h:: ++jrb
  39. +     add def for Psigpause() per MiNT 0.95 pl 1
  40. + osbind.h: ers
  41. +     Bconmap should be XBIOS call 0x2c, *not* 0x2b.
  42. +     0x2b is DMAwrite. There's obviously a potential for serious
  43. +     lossage here :-(. (mntlib has the same bug)
  44. + doprnt.c:: ers
  45. +     -- conditionalize prototypes so Sozobon can compile this
  46. +     -- use "+Inf", "-Inf", "NaN" instead of " Infinity ",
  47. +         " -Infinity ", and " Not A Number ". I'm told that
  48. +         ANSI specifies the shorter strings, and some programs
  49. +         rely on these.
  50. + *.h and some *.c:: ers/++jrb
  51. +     merge mntlib and lib headers. a few .c files needed adjustments
  52. +         because of this.
  53. + obstack.c/obstack.h:: ++jrb
  54. +     sanitize the ones from gcc 2.1 distribution for 16/32 ints and
  55. +         add to lib.
  56. + mincl:: ++jrb
  57. +     add target for obstack.c
  58. + bzero/bcmp/bcopy string.h:: ++jrb
  59. +         get rid of the silly old lbXXX aliases.
  60. +         add the MiNT _bxxx() aliases. should be useful with people like
  61. +         the soz 1.33 author who dont distinguish between an int and the size
  62. +         of an addressable object (under the guise of efficiency). big sigh!
  63. + malloc.c:: ++jrb
  64. +     split off realloc and calloc into their own files. put common
  65. +     definitions in lib.h so that it may be included in realloc.c
  66. +     and calloc.c.
  67. + realloc.c/calloc.c:: ++jrb
  68. +     new files.
  69. + mincl:: ++jrb
  70. +     add targets for realloc.o and calloc.o
  71. + lib.h:: ++jrb
  72. +     add common alloc defs
  73. +     cleanup
  74. + mincl: ++jrb
  75. +     in all the rules, change any explicitly specified source filename
  76. +     to $<, so that when VPATH is set the correct thing happens.
  77. + ---------------------------- Patchlevel 80.5 ---------------------------
  78. + *:: ers/++jrb
  79. +     start of merge of mnt/tos libs. all headers done. lots
  80. +     of common files done. lots of minor adjustments all
  81. +     over.
  82. + console.c:: scott
  83. +         We were doning a dev=LOOKUP(handle) in console_write_byte, than again
  84. +         in flush_key_buff()
  85. + eprintf.c:: ++jrb
  86. +     turn say into a routine that calculates the strlen. there was already
  87. +     a mistake there.
  88. + ---------------------------- Patchlevel 81 ---------------------------
  89. *** 1.56    1992/04/13 15:50:45
  90. --- PatchLev.h    1992/06/03 14:46:15
  91. ***************
  92. *** 1,5 ****
  93.   
  94. ! #define    PatchLevel "80"
  95.   
  96.   /*
  97.    *
  98. --- 1,5 ----
  99.   
  100. ! #define    PatchLevel "81"
  101.   
  102.   /*
  103.    *
  104. *** 1.14    1992/02/04 17:11:06
  105. --- close.c    1992/06/03 14:46:17
  106. ***************
  107. *** 8,13 ****
  108. --- 8,14 ----
  109.   #include    <fcntl.h>
  110.   #include    <device.h>
  111.   #include    <stdlib.h>
  112. + #include     <unistd.h>
  113.   
  114.   int (*pipeclose_p) __PROTO((int fd)) = 0;
  115.   
  116. *** 1.12    1992/04/13 15:50:45
  117. --- console.c    1992/06/03 14:46:17
  118. ***************
  119. *** 165,177 ****
  120.   int n;
  121.   {
  122.       char ch;
  123. -     short dev;
  124.   
  125. -     dev = LOOKUP(handle);
  126.       if (__check_signals)
  127. !         flush_key_buff(dev);
  128. ! /*    raw_out(dev, n); */
  129.       ch = n;
  130.       (void)Fwrite(handle, 1L, &ch);
  131.   }
  132. --- 165,173 ----
  133.   int n;
  134.   {
  135.       char ch;
  136.   
  137.       if (__check_signals)
  138. !         flush_key_buff(handle);
  139.       ch = n;
  140.       (void)Fwrite(handle, 1L, &ch);
  141.   }
  142. ***************
  143. *** 199,210 ****
  144.           ch = c & 0xff;
  145.           if (ch == ('S'-'@')) { waiting = 1; }
  146.           else if (ch == ('Q'-'@')) { waiting = 0; }
  147. !         else if (ch == __tchars[TC_INTRC]) 
  148.           { 
  149.           p->head = p->tail;
  150.           raise(SIGINT);
  151.           }
  152. !         else if (ch == __tchars[TC_QUITC]) 
  153.           { 
  154.           p->head = p->tail;
  155.           raise(SIGQUIT);
  156. --- 195,206 ----
  157.           ch = c & 0xff;
  158.           if (ch == ('S'-'@')) { waiting = 1; }
  159.           else if (ch == ('Q'-'@')) { waiting = 0; }
  160. !         else if (ch == (unsigned char)__tchars[TC_INTRC]) 
  161.           { 
  162.           p->head = p->tail;
  163.           raise(SIGINT);
  164.           }
  165. !         else if (ch == (unsigned char)__tchars[TC_QUITC]) 
  166.           { 
  167.           p->head = p->tail;
  168.           raise(SIGQUIT);
  169. *** 1.19    1992/04/19 16:02:45
  170. --- mincl    1992/06/03 14:46:21
  171. ***************
  172. *** 18,40 ****
  173.       bblink.o
  174.   #
  175.   # ANSI stuff + support
  176. ! ANSI =  atol.o atof.o abort.o bsearch.o clock.o ctime.o ctype.o difftime.o \
  177.       fopen.o fclose.o fdopen.o fflush.o fgetc.o fgets.o \
  178.       fputc.o fputs.o fread.o fwrite.o fseek.o fsetpos.o \
  179. !     fprintf.o sprintf.o \
  180.       fscanf.o scanf.o sscanf.o \
  181.       getenv.o putenv.o gets.o getw.o localtim.o \
  182. !     malloc.o qsort.o raise.o rand.o setbuf.o setvbuf.o \
  183.       setlocal.o strftime.o strtol.o system.o \
  184.       tmpnam.o tmpfile.o \
  185.       ltoa.o main.o doprnt.o div.o \
  186. !     strtoul.o fungetc.o filbuf.o getbuf.o
  187.   
  188.   #
  189.   # other portable stuff
  190.   PORT =  alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
  191.       getlogin.o getopt.o getpass.o ident.o mktemp.o scandir.o strlwr.o \
  192. !     strrev.o regexp.o regsup.o textio.o random.o
  193.   
  194.   #
  195.   # the string library
  196. --- 18,42 ----
  197.       bblink.o
  198.   #
  199.   # ANSI stuff + support
  200. ! ANSI =  atol.o atof.o abort.o bsearch.o \
  201. !     calloc.o clock.o ctime.o ctype.o difftime.o \
  202.       fopen.o fclose.o fdopen.o fflush.o fgetc.o fgets.o \
  203.       fputc.o fputs.o fread.o fwrite.o fseek.o fsetpos.o \
  204. !     fprintf.o eprintf.o sprintf.o \
  205.       fscanf.o scanf.o sscanf.o \
  206.       getenv.o putenv.o gets.o getw.o localtim.o \
  207. !     malloc.o qsort.o raise.o rand.o realloc.o \
  208. !     setbuf.o setvbuf.o \
  209.       setlocal.o strftime.o strtol.o system.o \
  210.       tmpnam.o tmpfile.o \
  211.       ltoa.o main.o doprnt.o div.o \
  212. !     strtoul.o fungetc.o filbuf.o getbuf.o toxxx.o
  213.   
  214.   #
  215.   # other portable stuff
  216.   PORT =  alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
  217.       getlogin.o getopt.o getpass.o ident.o mktemp.o scandir.o strlwr.o \
  218. !     strrev.o regexp.o regsup.o textio.o random.o obstack.o
  219.   
  220.   #
  221.   # the string library
  222. ***************
  223. *** 74,84 ****
  224.   #
  225.   # osbind.o/gmon.o/fork.o CANNOT have -fomit-frame-pointer
  226.   osbind.o: osbind.c
  227. !     $(CC) $(CFFLAGS) -c osbind.c
  228.   gmon.o: gmon.c
  229. !     $(CC) $(CFFLAGS) -c gmon.c
  230.   fork.o: fork.c
  231. !     $(CC) $(CFFLAGS) -c fork.c
  232.   
  233.   #
  234.   # Assembler stuff that needs to be preprocessed by cpp into a .S
  235. --- 76,86 ----
  236.   #
  237.   # osbind.o/gmon.o/fork.o CANNOT have -fomit-frame-pointer
  238.   osbind.o: osbind.c
  239. !     $(CC) $(CFFLAGS) -c $<
  240.   gmon.o: gmon.c
  241. !     $(CC) $(CFFLAGS) -c $<
  242.   fork.o: fork.c
  243. !     $(CC) $(CFFLAGS) -c $<
  244.   
  245.   #
  246.   # Assembler stuff that needs to be preprocessed by cpp into a .S
  247. ***************
  248. *** 111,124 ****
  249.   #
  250.   # integer only io stuff
  251.   idoprnt.o: doprnt.c
  252. !     $(CC) $(CFLAGS) -D__NO_FLOAT__ -c doprnt.c -o idoprnt.o
  253.   
  254.   iscanf.o: scanf.c
  255. !     $(CC) $(CFLAGS) -D__NO_FLOAT__ -c scanf.c -o iscanf.o
  256.   
  257.   # gcrt0
  258.   gcrt0.o: crt0.c
  259. !     $(CC) $(CFLAGS) -D__GCRT0__ -c crt0.c -o gcrt0.o
  260.   
  261.   # other dependencies
  262.   bcopy.o : bcopy.s
  263. --- 113,126 ----
  264.   #
  265.   # integer only io stuff
  266.   idoprnt.o: doprnt.c
  267. !     $(CC) $(CFLAGS) -D__NO_FLOAT__ -c $< -o idoprnt.o
  268.   
  269.   iscanf.o: scanf.c
  270. !     $(CC) $(CFLAGS) -D__NO_FLOAT__ -c $< -o iscanf.o
  271.   
  272.   # gcrt0
  273.   gcrt0.o: crt0.c
  274. !     $(CC) $(CFLAGS) -D__GCRT0__ -c $< -o gcrt0.o
  275.   
  276.   # other dependencies
  277.   bcopy.o : bcopy.s
  278. *** 1.11    1992/04/13 15:50:45
  279. --- mkdir.c    1992/06/03 14:46:21
  280. ***************
  281. *** 15,21 ****
  282.   
  283.   int mkdir(_path, mode)
  284.   const char *_path;
  285. ! int mode;
  286.   {
  287.       int rv, name_munged;
  288.       char path[FILENAME_MAX];
  289. --- 15,21 ----
  290.   
  291.   int mkdir(_path, mode)
  292.   const char *_path;
  293. ! unsigned int mode;
  294.   {
  295.       int rv, name_munged;
  296.       char path[FILENAME_MAX];
  297. *** 1.18    1992/04/13 15:50:45
  298. --- stat.c    1992/06/03 14:46:24
  299. ***************
  300. *** 37,43 ****
  301.   DIR *__opendir_chain = 0;    /* chain of open directories from opendir */
  302.   
  303.   /* date for files (like root directories) that don't have one */
  304. ! #define OLDDATE unixtime(0,0)
  305.   
  306.   /*
  307.    * check file cache for the file whose canonical (unx2dos) name is fullname.
  308. --- 37,43 ----
  309.   DIR *__opendir_chain = 0;    /* chain of open directories from opendir */
  310.   
  311.   /* date for files (like root directories) that don't have one */
  312. ! #define OLDDATE _unixtime(0,0)
  313.   
  314.   /*
  315.    * check file cache for the file whose canonical (unx2dos) name is fullname.
  316. ***************
  317. *** 184,190 ****
  318.           return -1;
  319.       }
  320.       st->st_mtime = st->st_ctime = st->st_atime =
  321. !         unixtime(d->d_time, d->d_date);
  322.       st->st_ino = d->d_ino;
  323.       st->st_attr = d->d_attribute;
  324.       st->st_mode = 0644 | (d->d_attribute & FA_DIR ?
  325. --- 184,190 ----
  326.           return -1;
  327.       }
  328.       st->st_mtime = st->st_ctime = st->st_atime =
  329. !         _unixtime(d->d_time, d->d_date);
  330.       st->st_ino = d->d_ino;
  331.       st->st_attr = d->d_attribute;
  332.       st->st_mode = 0644 | (d->d_attribute & FA_DIR ?
  333. ***************
  334. *** 289,295 ****
  335.           long oldplace;
  336.           
  337.           st->st_mtime = st->st_atime = st->st_ctime =
  338. !             unixtime(timestruct.time,timestruct.date);
  339.           st->st_mode = S_IFREG | 0644;        /* this may be false */
  340.           st->st_attr = 0;            /* because this is */
  341.           
  342. --- 289,295 ----
  343.           long oldplace;
  344.           
  345.           st->st_mtime = st->st_atime = st->st_ctime =
  346. !             _unixtime(timestruct.time,timestruct.date);
  347.           st->st_mode = S_IFREG | 0644;        /* this may be false */
  348.           st->st_attr = 0;            /* because this is */
  349.           
  350. *** 1.22    1992/04/19 16:02:45
  351. --- unx2dos.c    1992/06/03 14:46:26
  352. ***************
  353. *** 6,11 ****
  354. --- 6,12 ----
  355.   #include <types.h>
  356.   #include <dirent.h>
  357.   #include "symdir.h"
  358. + #include "lib.h"
  359.   #ifndef _COMPILER_H
  360.   #include <compiler.h>
  361.   #endif
  362. ***************
  363. *** 607,613 ****
  364.    */
  365.   
  366.   /* system default file name mapping function pointers */
  367. - typedef int (*fnmapfunc_t)(const char *, char *);
  368.   
  369.   static fnmapfunc_t ux2dos = _unx2dos;
  370.   static fnmapfunc_t dos2ux = _dos2unx;
  371. --- 608,613 ----
  372. *** 1.1    1992/04/06 19:33:32
  373. --- _fltsi.cpp    1992/06/03 14:49:07
  374. ***************
  375. *** 12,20 ****
  376.   
  377.   __floatsidf:
  378.   ___floatsidf:
  379. !     fmovel    a7@(4),fp0        | load long int to fp0
  380. !     fintrzd a4@(4),fp0        | get double from fp0
  381. !     fmoved    fp0,a7@-
  382.       moveml    a7@+,d0-d1
  383.        rts
  384.   
  385. --- 12,19 ----
  386.   
  387.   __floatsidf:
  388.   ___floatsidf:
  389. !     fintrzd a7@(4),fp0        | load long int to fp0
  390. !     fmoved    fp0,a7@-        | get double from fp0
  391.       moveml    a7@+,d0-d1
  392.        rts
  393.   
  394. *** 1.4    1991/04/26 03:42:08
  395. --- abort.c    1992/06/03 14:49:09
  396. ***************
  397. *** 1,8 ****
  398.   /* ERS */
  399.   
  400. - #include <stddef.h>
  401. - #include <stdlib.h>
  402.   #include <signal.h>
  403.   #include <unistd.h>
  404.   
  405.   #ifndef SIGABRT
  406. --- 1,7 ----
  407.   /* ERS */
  408.   
  409.   #include <signal.h>
  410. + #include <stdlib.h>
  411.   #include <unistd.h>
  412.   
  413.   #ifndef SIGABRT
  414. ***************
  415. *** 10,20 ****
  416.   #endif
  417.   
  418.   __EXITING abort()
  419. !     {
  420. ! #if 0 /* for now */
  421.       raise(SIGABRT);
  422. ! #else
  423. !     raise(SIGIOT);
  424. ! #endif
  425. !     exit(-999);
  426. !     }
  427. --- 9,15 ----
  428.   #endif
  429.   
  430.   __EXITING abort()
  431. ! {
  432.       raise(SIGABRT);
  433. !     exit(127);
  434. ! }
  435. *** 1.7    1991/04/12 18:19:53
  436. --- access.c    1992/06/03 14:49:09
  437. ***************
  438. *** 4,10 ****
  439. --- 4,13 ----
  440.   #include <stat.h>
  441.   #include <fcntl.h>
  442.   #include <errno.h>
  443. + #include <unistd.h>
  444.   
  445. + extern int __mint;
  446.   int
  447.   access(path, mode)
  448.       const char *path;
  449. ***************
  450. *** 11,16 ****
  451. --- 14,20 ----
  452.       int mode;
  453.   {
  454.       struct stat sb;
  455. +     int uid, gid;
  456.   
  457.       if (stat(path, &sb) < 0)
  458.           return -1;    /* errno was set by stat() */
  459. ***************
  460. *** 20,27 ****
  461.   /* somewhat crufty code -- relies on R_OK, etc. matching the bits in the
  462.      file mode, but what the heck, we can do this
  463.    */
  464. !     if ( ((sb.st_mode >> 6) & mode) == mode )
  465. !         return 0;
  466.   
  467.       errno = EACCESS; return -1;
  468.   }
  469. --- 24,45 ----
  470.   /* somewhat crufty code -- relies on R_OK, etc. matching the bits in the
  471.      file mode, but what the heck, we can do this
  472.    */
  473. !     if (__mint < 9 || ( (uid = geteuid()) == sb.st_uid ) ) {
  474. !         if ( ((sb.st_mode >> 6) & mode) == mode )
  475. !             return 0;
  476. !         else
  477. !             goto accdn;
  478. !     }
  479.   
  480. +     if ( (gid = getegid()) == sb.st_gid ) {
  481. +         if ( ((sb.st_mode >> 3) & mode) == mode )
  482. +             return 0;
  483. +         else
  484. +             goto accdn;
  485. +     }
  486. +     if ( (sb.st_mode & mode) == mode)
  487. +         return 0;
  488. + accdn:
  489.       errno = EACCESS; return -1;
  490.   }
  491. *** 1.5    1992/04/13 15:50:45
  492. --- alloca.s    1992/06/03 14:49:09
  493. ***************
  494. *** 19,24 ****
  495.       subl    d0,sp        | increase stack frame size by that much
  496.       movel    sp,d0        | set up to return it
  497.   
  498. !     subql    #4,sp        | new top of stack (real bug fix here)
  499.   
  500.       jmp    a0@        | return by jmping via saved addr
  501. --- 19,24 ----
  502.       subl    d0,sp        | increase stack frame size by that much
  503.       movel    sp,d0        | set up to return it
  504.   
  505. !     lea    sp@(-4),sp    | new top of stack (real bug fix here)
  506.   
  507.       jmp    a0@        | return by jmping via saved addr
  508. *** 1.10    1992/03/06 19:19:47
  509. --- bcmp.c    1992/06/03 14:49:10
  510. ***************
  511. *** 3,10 ****
  512.   #include <assert.h>
  513.   
  514.   #undef ODD
  515. ! #define ODD(x) (((short)(x)) & 1)    /* word ops are faster */
  516. ! #define INC(x, size) x = (const void *)(((const char *)(x)) + (size))
  517.   
  518.   /*
  519.    * compare n bytes efficientlty
  520. --- 3,9 ----
  521.   #include <assert.h>
  522.   
  523.   #undef ODD
  524. ! #define ODD(x) (((long)(x)) & 1)
  525.   
  526.   /*
  527.    * compare n bytes efficientlty
  528. ***************
  529. *** 13,19 ****
  530.    *
  531.    *   ++jrb  bammi@dsrgsun.ces.cwru.edu
  532.    */
  533. ! asm(".stabs \"_lbcmp\",5,0,0,_bcmp"); /* dept of clean tricks */
  534.   
  535.   int bcmp(src, dst, n)
  536.   const void * src;
  537. --- 12,19 ----
  538.    *
  539.    *   ++jrb  bammi@dsrgsun.ces.cwru.edu
  540.    */
  541. ! #define INC(x, size) x = (const void *)(((const char *)(x)) + (size))
  542.   
  543.   int bcmp(src, dst, n)
  544.   const void * src;
  545. ***************
  546. *** 20,25 ****
  547. --- 20,26 ----
  548.   const void * dst;
  549.   register size_t n;
  550.   {
  551.       assert ((src != NULL) && (dst != NULL));
  552.   
  553.       if((src != dst) && (n > 0))
  554. *** 1.5    1992/04/13 15:50:45
  555. --- bcopy.s    1992/06/03 14:49:11
  556. ***************
  557. *** 3,14 ****
  558.   |    handles overlap, odd/even alignment
  559.   |    uses movem to copy 256 bytes blocks faster.
  560.   |    Alexander Lehmann    alexlehm@iti.informatik.th-darmstadt.de
  561. ! |    sortof inspired by jrb's bcopy
  562.   
  563.       .text
  564.       .even
  565.       .globl _bcopy
  566. !     .globl _lbcopy
  567.       .globl _memcpy
  568.       .globl _memmove
  569.   
  570. --- 3,14 ----
  571.   |    handles overlap, odd/even alignment
  572.   |    uses movem to copy 256 bytes blocks faster.
  573.   |    Alexander Lehmann    alexlehm@iti.informatik.th-darmstadt.de
  574. ! |    sortof inspired by jrbs bcopy
  575.   
  576.       .text
  577.       .even
  578.       .globl _bcopy
  579. !     .globl    __bcopy
  580.       .globl _memcpy
  581.       .globl _memmove
  582.   
  583. ***************
  584. *** 29,35 ****
  585.   |    functions are aliased
  586.   
  587.   _bcopy:
  588. ! _lbcopy:
  589.       movl    sp@(4),a0    | src
  590.       movl    sp@(8),a1    | dest
  591.   common:    movl    sp@(12),d0    | length
  592. --- 29,35 ----
  593.   |    functions are aliased
  594.   
  595.   _bcopy:
  596. ! __bcopy:
  597.       movl    sp@(4),a0    | src
  598.       movl    sp@(8),a1    | dest
  599.   common:    movl    sp@(12),d0    | length
  600. ***************
  601. *** 49,55 ****
  602.       jne    slow_copy
  603.       btst    #0,d2        | both even ?
  604.       jeq    both_even
  605. !     movb    a0@+,a1@+    | copy one byte, now we're both even
  606.       subql    #1,d0
  607.   both_even:
  608.       clrw    d1        | save length less 256
  609. --- 49,55 ----
  610.       jne    slow_copy
  611.       btst    #0,d2        | both even ?
  612.       jeq    both_even
  613. !     movb    a0@+,a1@+    | copy one byte, now we are both even
  614.       subql    #1,d0
  615.   both_even:
  616.       clrw    d1        | save length less 256
  617. *** 1.7    1991/04/26 03:42:08
  618. --- bsearch.c    1992/06/03 14:49:11
  619. ***************
  620. *** 30,36 ****
  621.       while(a <= b)
  622.           {
  623.           c = (a + b) >> 1;    /* == ((a + b) / 2) */
  624. !         if (dir = (*cmp)((void *)((char *)base + c * size), key))
  625.               {
  626.               if (dir > 0)
  627.               {
  628. --- 30,36 ----
  629.       while(a <= b)
  630.           {
  631.           c = (a + b) >> 1;    /* == ((a + b) / 2) */
  632. !         if (dir = (*cmp)((void *)((char *)base + (c * size)), key))
  633.               {
  634.               if (dir > 0)
  635.               {
  636. *** 1.1    1992/04/06 19:33:32
  637. --- bzero.cpp    1992/06/03 14:49:11
  638. ***************
  639. *** 1,4 ****
  640.   |    new version of bcopy and memset
  641.   |    uses movem to set 256 bytes blocks faster.
  642.   |    Alexander Lehmann    alexlehm@iti.informatik.th-darmstadt.de
  643. --- 1,3 ----
  644. ***************
  645. *** 8,14 ****
  646.       .text
  647.       .even
  648.       .globl _bzero
  649. !     .globl _lbzero
  650.       .globl _memset
  651.   
  652.   |    void *memset( void *dest, int val, size_t len );
  653. --- 7,13 ----
  654.       .text
  655.       .even
  656.       .globl _bzero
  657. !     .globl __bzero
  658.       .globl _memset
  659.   
  660.   |    void *memset( void *dest, int val, size_t len );
  661. ***************
  662. *** 28,38 ****
  663.       jra    do_set
  664.   
  665.   |    void bzero( void *dest, size_t length );
  666. ! |    void lbzero( void *dest, size_t length );
  667.   |    return value not used (returns dest)
  668.   
  669.   _bzero:
  670. ! _lbzero:
  671.       movl    sp@(4),a0    | dest
  672.       movl    sp@(8),d1    | length
  673.       jeq    exit        | length==0? (size_t)
  674. --- 27,37 ----
  675.       jra    do_set
  676.   
  677.   |    void bzero( void *dest, size_t length );
  678. ! |    void _bzero( void *dest, size_t length );
  679.   |    return value not used (returns dest)
  680.   
  681.   _bzero:
  682. ! __bzero:
  683.       movl    sp@(4),a0    | dest
  684.       movl    sp@(8),d1    | length
  685.       jeq    exit        | length==0? (size_t)
  686. *** 1.9    1991/06/11 23:04:27
  687. --- chdir.c    1992/06/03 14:49:12
  688. ***************
  689. *** 1,9 ****
  690. - #include <stdio.h>
  691.   #include <errno.h>
  692.   #include <osbind.h>
  693.   #include <stddef.h>
  694.   #include <assert.h>
  695.   #include <ctype.h>
  696.   #include <unistd.h>
  697.   #include "lib.h"
  698.   
  699. --- 1,9 ----
  700.   #include <errno.h>
  701.   #include <osbind.h>
  702.   #include <stddef.h>
  703.   #include <assert.h>
  704.   #include <ctype.h>
  705. + #include <limits.h>
  706.   #include <unistd.h>
  707.   #include "lib.h"
  708.   
  709. ***************
  710. *** 17,23 ****
  711.   {
  712.       int drv, old;
  713.       int r;
  714. !     char tmp[FILENAME_MAX];
  715.       register char *d;
  716.   
  717.       assert ((dir != NULL));
  718. --- 17,23 ----
  719.   {
  720.       int drv, old;
  721.       int r;
  722. !     char tmp[PATH_MAX];
  723.       register char *d;
  724.   
  725.       assert ((dir != NULL));
  726. *** 1.5    1991/06/11 23:04:27
  727. --- chmod.c    1992/06/03 14:49:12
  728. ***************
  729. *** 5,16 ****
  730.   #include <types.h>
  731.   #include <stat.h>
  732.   #include <osbind.h>
  733. ! #include <stdio.h>
  734.   #include <errno.h>
  735.   #include <unistd.h>
  736. - #include <support.h>
  737.   #include "lib.h"
  738.   
  739.   
  740.   int chmod(_path, mode)
  741.          const char *_path;
  742. --- 5,17 ----
  743.   #include <types.h>
  744.   #include <stat.h>
  745.   #include <osbind.h>
  746. ! #include <mintbind.h>
  747. ! #include <limits.h>
  748.   #include <errno.h>
  749.   #include <unistd.h>
  750.   #include "lib.h"
  751.   
  752. + extern int __mint;
  753.   
  754.   int chmod(_path, mode)
  755.          const char *_path;
  756. ***************
  757. *** 17,31 ****
  758.          int   mode;
  759.   {
  760.          int  dosattrib = 0, r;
  761. !        char path[FILENAME_MAX];
  762.          struct stat stb;
  763.   
  764.          (void)unx2dos(_path, path);
  765.   
  766. !     /* The following lines ensure that the archive bit isn't cleared */
  767. !         r = Fattrib(path, 0, dosattrib);
  768. !         if (r > 0 && (r & FA_CHANGED))
  769. !                 dosattrib |= FA_CHANGED;
  770.   #if 0
  771.          if (!(mode & S_IREAD))
  772.                  dosattrib |= FA_HIDDEN;
  773. --- 18,42 ----
  774.          int   mode;
  775.   {
  776.          int  dosattrib = 0, r;
  777. !        char path[PATH_MAX];
  778.          struct stat stb;
  779.   
  780.          (void)unx2dos(_path, path);
  781.   
  782. !     if (__mint >= 9) {    /* use MiNT Fchmod function */
  783. !         r = Fchmod(path, mode);
  784. !         if (r) {
  785. !             errno = -r;
  786. !             return -1;
  787. !         }
  788. !         return 0;
  789. !     }
  790. ! /* The following lines ensure that the archive bit isn't cleared */
  791. !     r = Fattrib(path, 0, dosattrib);
  792. !      if (r > 0 && (r & FA_CHANGED))
  793. !         dosattrib |= FA_CHANGED;
  794.   #if 0
  795.          if (!(mode & S_IREAD))
  796.                  dosattrib |= FA_HIDDEN;
  797. ***************
  798. *** 45,55 ****
  799.          return 0;
  800.   }
  801.   
  802. ! /* just fake these for now */
  803.   
  804. ! int chown(name, uid, gid)
  805. !        const char *name;
  806.          int uid, gid;
  807.   {
  808. !        return 0;
  809.   }
  810. --- 56,80 ----
  811.          return 0;
  812.   }
  813.   
  814. ! /*
  815. !  * chown: this is faked if MiNT is not running
  816. !  */
  817.   
  818. ! int chown(_name, uid, gid)
  819. !        const char *_name;
  820.          int uid, gid;
  821.   {
  822. !     int r;
  823. !     char name[PATH_MAX];
  824. !     if (__mint >= 9) {
  825. !         (void)unx2dos(_name, name);
  826. !         r = Fchown(name, uid, gid);
  827. !         if (r) {
  828. !             errno = -r;
  829. !             return -1;
  830. !         }
  831. !         return 0;
  832. !     }
  833. !     return 0;
  834.   }
  835. *** 1.7    1992/03/06 19:19:47
  836. --- ctype.c    1992/06/03 14:49:13
  837. ***************
  838. *** 65,79 ****
  839.       };
  840.   
  841.   unsigned char *_ctype = &(_myctype[0]);
  842. - int toupper(c)
  843. -     int c;
  844. -     {
  845. -     return(islower(c) ? (c ^ 0x20) : (c));
  846. -     }
  847. - int tolower(c)
  848. -     int c;
  849. -     {
  850. -     return(isupper(c) ? (c ^ 0x20) : (c));
  851. -     }
  852. --- 65,67 ----
  853. *** 1.14    1992/04/19 16:02:45
  854. --- doprnt.c    1992/06/03 14:49:14
  855. ***************
  856. *** 52,60 ****
  857. --- 52,62 ----
  858.   #include    <math.h>    /* mjr++    */
  859.   
  860.   #ifndef __GNUC__    /* gcc lib has these typedefs in sys/types.h */
  861. + #ifndef __MINT__    /* as does the MiNT library */
  862.   typedef unsigned char u_char;
  863.   typedef unsigned long u_long;
  864.   #endif
  865. + #endif
  866.   
  867.   /* 11-bit exponent (VAX G floating point) is 308 decimal digits */
  868.   #define    MAXEXP        308
  869. ***************
  870. *** 314,320 ****
  871.               if (_dd.i[0] == NAN_HI)
  872.               {
  873.                   t = buf;
  874. !                 t = strcpy(t, " Not A Number ");
  875.                   size = strlen(t);
  876.                   goto pforw;
  877.               }
  878. --- 316,322 ----
  879.               if (_dd.i[0] == NAN_HI)
  880.               {
  881.                   t = buf;
  882. !                 t = strcpy(t, "NaN");
  883.                   size = strlen(t);
  884.                   goto pforw;
  885.               }
  886. ***************
  887. *** 345,353 ****
  888.                 {
  889.                   t = buf;
  890.                   if(softsign == 0)
  891. !                 t = strcpy(t, " Infinity ");
  892.                   else
  893. !                 t = strcpy(t, " -Infinity ");
  894.                   size = strlen(t);
  895.                   goto pforw;
  896.               }
  897. --- 347,355 ----
  898.                 {
  899.                   t = buf;
  900.                   if(softsign == 0)
  901. !                 t = strcpy(t, "+Inf");
  902.                   else
  903. !                 t = strcpy(t, "-Inf");
  904.                   size = strlen(t);
  905.                   goto pforw;
  906.               }
  907. ***************
  908. *** 400,406 ****
  909.                    * NUL in the first `prec' characters, and
  910.                    * strlen() will go further.
  911.                    */
  912. ! #ifdef __GNUC__
  913.                   char *p;
  914.                   void *memchr(const void *, int, size_t);
  915.   #else
  916. --- 402,408 ----
  917.                    * NUL in the first `prec' characters, and
  918.                    * strlen() will go further.
  919.                    */
  920. ! #ifdef __STDC__
  921.                   char *p;
  922.                   void *memchr(const void *, int, size_t);
  923.   #else
  924. ***************
  925. *** 538,544 ****
  926.       register char *p, *t;
  927.       register double fract;
  928.       int dotrim, expcnt, gformat;
  929. !     double integer, tmp, modf(double, double *);
  930.       char *exponent __PROTO((char *, int, int)),
  931.            *round __PROTO((double, int *, char *, char *, int, char *));
  932.   
  933. --- 540,546 ----
  934.       register char *p, *t;
  935.       register double fract;
  936.       int dotrim, expcnt, gformat;
  937. !     double integer, tmp, modf __PROTO((double, double *));
  938.       char *exponent __PROTO((char *, int, int)),
  939.            *round __PROTO((double, int *, char *, char *, int, char *));
  940.   
  941. *** 1.7    1991/04/26 03:42:08
  942. --- fclose.c    1992/06/03 14:49:15
  943. ***************
  944. *** 4,9 ****
  945. --- 4,11 ----
  946.   #include <stdlib.h>
  947.   #include <unistd.h>
  948.   
  949. + extern int __mint;
  950.   int fclose(fp)
  951.       register FILE *fp;
  952.       {
  953. ***************
  954. *** 37,44 ****
  955.           }
  956.   #endif
  957.       fp->_flag = 0;            /* clear status */
  958. !     if(f & _IODEV)            /* leave tty's alone */
  959. !         return(0);
  960.       error |= close(fp->_file);
  961.       return(error ? EOF : 0);
  962.       }
  963. --- 39,47 ----
  964.           }
  965.   #endif
  966.       fp->_flag = 0;            /* clear status */
  967. !     if (__mint  == 0)
  968. !         if(f & _IODEV)            /* leave tty's alone */
  969. !             return(0);
  970.       error |= close(fp->_file);
  971.       return(error ? EOF : 0);
  972.       }
  973. *** 1.10    1992/03/06 19:19:47
  974. --- fdopen.c    1992/06/03 14:49:15
  975. ***************
  976. *** 8,14 ****
  977.   FILE *fdopen(h, mode)
  978.       register int h;
  979.       const register char *mode;
  980. !     {
  981.       extern int __default_mode__;    /* see binmode.c */
  982.       register int i, iomode = 0, f = __default_mode__;
  983.       register FILE *fp = NULL;
  984. --- 8,14 ----
  985.   FILE *fdopen(h, mode)
  986.       register int h;
  987.       const register char *mode;
  988. ! {
  989.       extern int __default_mode__;    /* see binmode.c */
  990.       register int i, iomode = 0, f = __default_mode__;
  991.       register FILE *fp = NULL;
  992. ***************
  993. *** 17,31 ****
  994.       for(i=0; (!fp && (i < _NFILE)); ++i)
  995.           if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
  996.               fp = &_iob[i];    /* empty slot */
  997. !     if(!fp)
  998. !       {
  999. !         errno = EMFILE;
  1000. !         return(NULL);
  1001. !       }
  1002. !     while(*mode)
  1003. !         {
  1004. !         switch(*mode++)
  1005. !             {
  1006.               case 'r':
  1007.                   f |= _IOREAD;
  1008.                   break;
  1009. --- 17,29 ----
  1010.       for(i=0; (!fp && (i < _NFILE)); ++i)
  1011.           if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
  1012.               fp = &_iob[i];    /* empty slot */
  1013. !     if(!fp) {
  1014. !         errno = EMFILE;
  1015. !         return(NULL);
  1016. !     }
  1017. !     while(*mode) {
  1018. !         switch(*mode++) {
  1019.               case 'r':
  1020.                   f |= _IOREAD;
  1021.                   break;
  1022. ***************
  1023. *** 47,56 ****
  1024.               case 't':
  1025.                   f &= ~_IOBIN;
  1026.                   break;
  1027. !             default:    /* Illegal file mode */
  1028.                   return(NULL);
  1029.               }
  1030. !         }
  1031.       if((i = (f & (_IORW | _IOREAD | _IOWRT))) == 0)
  1032.           return(NULL);
  1033.       else if(i == _IOREAD)
  1034. --- 45,54 ----
  1035.               case 't':
  1036.                   f &= ~_IOBIN;
  1037.                   break;
  1038. !             default:        /* illegal file mode */
  1039.                   return(NULL);
  1040.               }
  1041. !     }
  1042.       if((i = (f & (_IORW | _IOREAD | _IOWRT))) == 0)
  1043.           return(NULL);
  1044.       else if(i == _IOREAD)
  1045. ***************
  1046. *** 59,64 ****
  1047. --- 57,63 ----
  1048.           iomode |= O_WRONLY;
  1049.       else
  1050.           iomode |= O_RDWR;
  1051.       if(isatty(h))
  1052.           f |= (_IODEV | _IONBF);
  1053.       else
  1054. ***************
  1055. *** 65,77 ****
  1056.           f |= _IOFBF;
  1057.       fp->_file = h;            /* file handle */
  1058.       fp->_flag = f;            /* file status flags */
  1059. - #if 0
  1060. -     fp->_base = NULL;        /* base of file buffer */
  1061. -     fp->_ptr = NULL;        /* current buffer pointer */
  1062. -     fp->_bsiz = 0;            /* buffer size */
  1063. -     fp->_cnt = 0;            /* # of bytes in buffer */
  1064. - #else
  1065.       _getbuf(fp);
  1066. - #endif
  1067.       return(fp);
  1068. !     }
  1069. --- 64,69 ----
  1070.           f |= _IOFBF;
  1071.       fp->_file = h;            /* file handle */
  1072.       fp->_flag = f;            /* file status flags */
  1073.       _getbuf(fp);
  1074.       return(fp);
  1075. ! }
  1076. *** 1.4    1991/04/12 18:19:53
  1077. --- fgets.c    1992/06/03 14:49:16
  1078. ***************
  1079. *** 13,19 ****
  1080.       register int c = EOF;
  1081.   
  1082.       assert((data != NULL));
  1083. !     
  1084.       while((--limit > 0) && ((c = getc(fp)) != EOF))
  1085.           if((*p++ = c) == '\n')
  1086.               break;
  1087. --- 13,19 ----
  1088.       register int c = EOF;
  1089.   
  1090.       assert((data != NULL));
  1091.       while((--limit > 0) && ((c = getc(fp)) != EOF))
  1092.           if((*p++ = c) == '\n')
  1093.               break;
  1094. *** 1.9    1991/12/26 15:53:59
  1095. --- findfile.c    1992/06/03 14:49:16
  1096. ***************
  1097. *** 9,22 ****
  1098.      Written by Eric R. Smith and placed in the public domain.
  1099.   */
  1100.   
  1101. ! #include <stdio.h>    /* needed only for FILENAME_MAX */
  1102.   #include <stddef.h>
  1103.   #include <types.h>
  1104.   #include <stat.h>
  1105.   #include <string.h>
  1106. - #ifndef _COMPILER_H
  1107. - #include <compiler.h>
  1108. - #endif
  1109.   
  1110.   /* characters used to separate components in a path list */
  1111.   #define PATHSEP1        ':'
  1112. --- 9,19 ----
  1113.      Written by Eric R. Smith and placed in the public domain.
  1114.   */
  1115.   
  1116. ! #include <limits.h>    /* needed for PATH_MAX */
  1117.   #include <stddef.h>
  1118.   #include <types.h>
  1119.   #include <stat.h>
  1120.   #include <string.h>
  1121.   
  1122.   /* characters used to separate components in a path list */
  1123.   #define PATHSEP1        ':'
  1124. ***************
  1125. *** 28,35 ****
  1126.   
  1127.   static char *nullext[] = { NULL };
  1128.   
  1129. - static int EXISTS __PROTO((char *name));
  1130.   static int
  1131.   EXISTS(name)
  1132.       char *name;
  1133. --- 25,30 ----
  1134. ***************
  1135. *** 47,53 ****
  1136.   findfile(fname, fpath, fext)
  1137.           char *fname, *fpath, **fext;
  1138.   {
  1139. !         static char try[FILENAME_MAX];
  1140.           char *s, *t, *extplace, **nextext, c;
  1141.           int  hasext = 0, haspath = 0;
  1142.   
  1143. --- 42,48 ----
  1144.   findfile(fname, fpath, fext)
  1145.           char *fname, *fpath, **fext;
  1146.   {
  1147. !         static char try[PATH_MAX];
  1148.           char *s, *t, *extplace, **nextext, c;
  1149.           int  hasext = 0, haspath = 0;
  1150.   
  1151. *** 1.16    1992/01/29 20:58:29
  1152. --- fopen.c    1992/06/03 14:49:16
  1153. ***************
  1154. *** 5,13 ****
  1155.   #include <fcntl.h>
  1156.   #include <unistd.h>
  1157.   #include <errno.h>
  1158. - #ifndef _COMPILER_H
  1159. - #include <compiler.h>
  1160. - #endif
  1161.   
  1162.   __EXTERN void _getbuf __PROTO((FILE *));
  1163.   
  1164. --- 5,10 ----
  1165. ***************
  1166. *** 16,23 ****
  1167.   
  1168.   extern int __default_mode__;
  1169.   
  1170. - static FILE *_fopen __PROTO((const char *filename, const char *mode, FILE *fp));
  1171.   static FILE *_fopen(filename, mode, fp)
  1172.       const char *filename;
  1173.       const register char *mode;
  1174. --- 13,18 ----
  1175. ***************
  1176. *** 54,60 ****
  1177.               case 't':
  1178.                   f &= ~_IOBIN;
  1179.                   break;
  1180. !             default:    /* Illegal file mode */
  1181.                   return(NULL);
  1182.               }
  1183.           }
  1184. --- 49,55 ----
  1185.               case 't':
  1186.                   f &= ~_IOBIN;
  1187.                   break;
  1188. !             default:
  1189.                   return(NULL);
  1190.               }
  1191.           }
  1192. ***************
  1193. *** 85,91 ****
  1194.       const char *filename, *mode;
  1195.       {
  1196.       register int i;
  1197. !         register FILE *fp = NULL;
  1198.   
  1199.       for(i=0; (!fp && (i < _NFILE)); ++i)
  1200.           if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT))) 
  1201. --- 80,86 ----
  1202.       const char *filename, *mode;
  1203.       {
  1204.       register int i;
  1205. !     register FILE *fp = NULL;
  1206.   
  1207.       for(i=0; (!fp && (i < _NFILE)); ++i)
  1208.           if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT))) 
  1209. ***************
  1210. *** 99,111 ****
  1211.       }
  1212.       else
  1213.         {
  1214. !         errno = EMFILE;
  1215. !         return NULL;
  1216.         }
  1217.       }
  1218.   
  1219.   /*
  1220. !  * re-coded,  foobared code ifdef'ed below
  1221.    *
  1222.    *    ++jrb
  1223.    */
  1224. --- 94,106 ----
  1225.       }
  1226.       else
  1227.         {
  1228. !         errno = EMFILE;
  1229. !         return NULL;
  1230.         }
  1231.       }
  1232.   
  1233.   /*
  1234. !  * re-coded,  foobared code deleted
  1235.    *
  1236.    *    ++jrb
  1237.    */
  1238. ***************
  1239. *** 124,131 ****
  1240.           if(fflush(fp) != 0) return NULL;            /* flush err */
  1241.           if(close(fp->_file) != 0) return NULL;        /* close err */
  1242.   #else
  1243. !         /* ANSI says ignore errors */
  1244. !         (void)fflush(fp); (void)close(fp->_file);
  1245.   #endif
  1246.       }
  1247.       /* save buffer discipline and setbuf settings, and _IOWRT just for
  1248. --- 119,125 ----
  1249.           if(fflush(fp) != 0) return NULL;            /* flush err */
  1250.           if(close(fp->_file) != 0) return NULL;        /* close err */
  1251.   #else
  1252. !     fflush(fp); close(fp->_file);        /* ANSI says ignore errors */
  1253.   #endif
  1254.       }
  1255.       /* save buffer discipline and setbuf settings, and _IOWRT just for
  1256. *** 1.14    1991/06/20 02:12:19
  1257. --- fprintf.c    1992/06/03 14:49:17
  1258. ***************
  1259. *** 1,58 ****
  1260. - /* from Dale Schumacher's dLibs */
  1261.   #include <stdio.h>
  1262.   #include <stdarg.h>
  1263. - #include <compiler.h>
  1264.   #include "lib.h"
  1265.   
  1266. ! __EXTERN int _doprnt __PROTO((FILE *file, const char *fmt, va_list argp));
  1267.   
  1268. ! #ifdef __STDC__
  1269.   int fprintf(FILE *fp, const char *fmt, ...)
  1270.   #else
  1271. ! int fprintf(fp, fmt)
  1272. !     FILE *fp;
  1273. !     const char *fmt;
  1274.   #endif
  1275. !     {
  1276. !     va_list argp;
  1277. !     va_start(argp, fmt);
  1278. !     return(_doprnt(fp, fmt, argp));
  1279. !     }
  1280.   
  1281. ! int vfprintf(fp, fmt, args)
  1282.       FILE *fp;
  1283.       const char *fmt;
  1284.       va_list args;
  1285. !     {
  1286.       return(_doprnt(fp, fmt, args));
  1287. !     }
  1288.   
  1289. ! #ifdef __STDC__
  1290.   int printf(const char *fmt, ...)
  1291.   #else
  1292. ! int printf(fmt)
  1293. !     const char *fmt;
  1294.   #endif
  1295. !     {
  1296. !     va_list argp;
  1297. !     va_start(argp, fmt);
  1298. !     return(_doprnt(stdout, fmt, argp));
  1299. !     }
  1300.   
  1301. ! int vprintf(fmt, args)
  1302.       const char *fmt;
  1303.       va_list args;
  1304. -     {
  1305. -     return(_doprnt(stdout, fmt, args));
  1306. -     }
  1307. - /* This is used by the `assert' macro.  */
  1308. - void __eprintf (string, expression, line, filename)
  1309. - const char *string;
  1310. - const char *expression;
  1311. - const long line;
  1312. - const char *filename; /* note if STDC then filename is already in string */
  1313.   {
  1314. !     (void)fprintf(stderr, string, expression, line, filename);
  1315.   }
  1316. --- 1,53 ----
  1317.   #include <stdio.h>
  1318.   #include <stdarg.h>
  1319.   #include "lib.h"
  1320.   
  1321. ! /* revised 4/15/92 sb -- moved __eprintf to a separate file to avoid conflict
  1322. !    with libm.a's printf */
  1323.   
  1324. ! #if __STDC__
  1325.   int fprintf(FILE *fp, const char *fmt, ...)
  1326.   #else
  1327. ! int fprintf(fp, fmt) FILE *fp; const char *fmt;
  1328.   #endif
  1329. ! {
  1330. !     int r;
  1331. !     va_list args;
  1332. !     va_start(args, fmt);
  1333. !     r = _doprnt(fp, fmt, args);
  1334. !     va_end(args);
  1335. !     return r;
  1336. ! }
  1337.   
  1338. ! int
  1339. ! vfprintf(fp, fmt, args)
  1340.       FILE *fp;
  1341.       const char *fmt;
  1342.       va_list args;
  1343. ! {
  1344.       return(_doprnt(fp, fmt, args));
  1345. ! }
  1346.   
  1347. ! #if __STDC__
  1348.   int printf(const char *fmt, ...)
  1349.   #else
  1350. ! int printf(fmt) const char *fmt;
  1351.   #endif
  1352. ! {
  1353. !     va_list args;
  1354. !     int r;
  1355. !     va_start(args, fmt);
  1356. !     r = _doprnt(stdout, fmt, args);
  1357. !     va_end(args);
  1358. !     return r;
  1359. ! }
  1360.   
  1361. ! int
  1362. ! vprintf(fmt, args)
  1363.       const char *fmt;
  1364.       va_list args;
  1365.   {
  1366. !     return(_doprnt(stdout, fmt, args));
  1367.   }
  1368. *** 1.11    1992/01/29 20:58:29
  1369. --- fputc.c    1992/06/03 14:49:17
  1370. ***************
  1371. *** 1,7 ****
  1372.   /* from Dale Schumacher's dLibs */
  1373.   
  1374.   #include <stdio.h>
  1375. - #include <unistd.h>
  1376.   #include "lib.h"
  1377.   
  1378.   #ifndef TRUE
  1379. --- 1,6 ----
  1380. ***************
  1381. *** 12,18 ****
  1382.   int fputc(c, fp)
  1383.           register int c;
  1384.       register FILE *fp;
  1385. !     {
  1386.       register int nl = FALSE;
  1387.       register long m;
  1388.       unsigned int f = fp->_flag;
  1389. --- 11,17 ----
  1390.   int fputc(c, fp)
  1391.           register int c;
  1392.       register FILE *fp;
  1393. ! {
  1394.       register int nl = FALSE;
  1395.       register long m;
  1396.       unsigned int f = fp->_flag;
  1397. ***************
  1398. *** 23,54 ****
  1399.           f = (fp->_flag &= ~(_IOREAD | _IOEOF));
  1400.       }
  1401.       if(!(f & _IOWRT)            /* not opened for write? */
  1402. !     || (f & (_IOERR | _IOEOF)))        /* error/eof conditions? */
  1403.           return(EOF);
  1404.   
  1405.       if(!(f & _IOBIN) && (c == '\n'))    /* NL -> CR+LF ? */
  1406. !         {
  1407.           c = '\r';
  1408.           nl = TRUE;
  1409. !         }
  1410.   _fputc:
  1411.       *(fp->_ptr)++ = c; fp->_cnt++;
  1412.       if( (fp->_cnt >= fp->_bsiz) || 
  1413.           ((f & _IOLBF) && (c == '\n'))  ) /* flush line buffd stream on \n */
  1414. !         {
  1415.           m = fp->_cnt;
  1416.           fp->_cnt = 0;
  1417.           fp->_ptr = fp->_base;
  1418. !         if(_write(fp->_file, fp->_base, m) != m)
  1419. !             {
  1420.               fp->_flag |= _IOERR;
  1421.               return(EOF);
  1422. -             }
  1423.           }
  1424. !     if(nl && (c == '\r'))            /* NL -> CR+LF ? */
  1425. !         {
  1426.           c = '\n';
  1427.           goto _fputc;
  1428. -         }
  1429. -     return(c & 0xff);
  1430.       }
  1431. --- 22,51 ----
  1432.           f = (fp->_flag &= ~(_IOREAD | _IOEOF));
  1433.       }
  1434.       if(!(f & _IOWRT)            /* not opened for write? */
  1435. !        || (f & (_IOERR | _IOEOF)))        /* error/eof conditions? */
  1436.           return(EOF);
  1437.   
  1438.       if(!(f & _IOBIN) && (c == '\n'))    /* NL -> CR+LF ? */
  1439. !     {
  1440.           c = '\r';
  1441.           nl = TRUE;
  1442. !     }
  1443.   _fputc:
  1444.       *(fp->_ptr)++ = c; fp->_cnt++;
  1445.       if( (fp->_cnt >= fp->_bsiz) || 
  1446.           ((f & _IOLBF) && (c == '\n'))  ) /* flush line buffd stream on \n */
  1447. !     {
  1448.           m = fp->_cnt;
  1449.           fp->_cnt = 0;
  1450.           fp->_ptr = fp->_base;
  1451. !         if(_write(fp->_file, fp->_base, m) != m) {
  1452.               fp->_flag |= _IOERR;
  1453.               return(EOF);
  1454.           }
  1455. !     }
  1456. !     if(nl && (c == '\r')) {            /* NL -> CR+LF ? */
  1457.           c = '\n';
  1458.           goto _fputc;
  1459.       }
  1460. +     return(c & 0xff);
  1461. + }
  1462. *** 1.6    1992/03/06 19:19:47
  1463. --- ftw.c    1992/06/03 14:49:18
  1464. ***************
  1465. *** 18,28 ****
  1466.   int
  1467.   ftw(directory, funcptr, depth)
  1468.       char         *directory;
  1469. - #if __STDC__
  1470. -     int            (*funcptr)(char *name, struct stat *statp, int flag);
  1471. - #else
  1472.       int            (*funcptr)();
  1473. - #endif
  1474.       int              depth;
  1475.   {
  1476.       register DIR     *dirp;
  1477. --- 18,24 ----
  1478. ***************
  1479. *** 30,39 ****
  1480. --- 26,39 ----
  1481.       struct stat          stats;
  1482.       register char     *p;
  1483.       register int      i;
  1484. + #ifndef __MINT__
  1485.       long          seekpoint;
  1486. + #endif
  1487.       char         *fullpath;
  1488.   
  1489. + #ifndef __MINT__
  1490.       seekpoint = 0;    /* avoid spurious warning from gcc -Wall */
  1491. + #endif
  1492.   
  1493.       /* If can't stat, tell the user so. */
  1494.       if (stat(directory, &stats) < 0)
  1495. ***************
  1496. *** 58,64 ****
  1497.   
  1498.       /* Get ready to hold the full paths. */
  1499.       i = strlen(directory);
  1500. !     fullpath = malloc((size_t)(i + 1 + MAXNAMLEN + 1));
  1501.       if (fullpath == NULL) {
  1502.       closedir(dirp);
  1503.       return -1;
  1504. --- 58,64 ----
  1505.   
  1506.       /* Get ready to hold the full paths. */
  1507.       i = strlen(directory);
  1508. !     fullpath = (char *) malloc( (size_t) (i + 1 + MAXNAMLEN + 1) );
  1509.       if (fullpath == NULL) {
  1510.       closedir(dirp);
  1511.       return -1;
  1512. ***************
  1513. *** 71,76 ****
  1514. --- 71,77 ----
  1515.       /* Read all entries in the directory.. */
  1516.       while (entp = readdir(dirp))
  1517.       if (!EQ(entp->d_name, ".") && !EQ(entp->d_name, "..")) {
  1518. + #ifndef __MINT__
  1519.           if (depth <= 1) {
  1520.           /* Going too deep; checkpoint and close this directory. */
  1521.           seekpoint = telldir(dirp);
  1522. ***************
  1523. *** 77,83 ****
  1524.           closedir(dirp);
  1525.           dirp = NULL;
  1526.           }
  1527.           /* Process the file. */
  1528.           (void)strcpy(p, entp->d_name);
  1529.           i = ftw(fullpath, funcptr, depth - 1);
  1530. --- 78,84 ----
  1531.           closedir(dirp);
  1532.           dirp = NULL;
  1533.           }
  1534. ! #endif
  1535.           /* Process the file. */
  1536.           (void)strcpy(p, entp->d_name);
  1537.           i = ftw(fullpath, funcptr, depth - 1);
  1538. ***************
  1539. *** 89,94 ****
  1540. --- 90,96 ----
  1541.           return i;
  1542.           }
  1543.   
  1544. + #ifndef __MINT__
  1545.           /* Reopen the directory if necessary. */
  1546.           if (dirp == NULL) {
  1547.           dirp = opendir(directory);
  1548. ***************
  1549. *** 98,103 ****
  1550. --- 100,106 ----
  1551.           }
  1552.           seekdir(dirp, seekpoint);
  1553.           }
  1554. + #endif
  1555.       }
  1556.   
  1557.       /* Clean up. */
  1558. *** 1.6    1992/03/22 21:57:30
  1559. --- getlogin.c    1992/06/03 14:49:19
  1560. ***************
  1561. *** 3,13 ****
  1562.    */
  1563.   
  1564.   #include <pwd.h>
  1565. - #include <support.h>
  1566. - #include <unistd.h>
  1567.   #include <string.h>
  1568.   #include <stdlib.h>
  1569.   #include <memory.h>
  1570.   
  1571.   static char *logname = NULL;
  1572.   
  1573. --- 3,16 ----
  1574.    */
  1575.   
  1576.   #include <pwd.h>
  1577.   #include <string.h>
  1578.   #include <stdlib.h>
  1579.   #include <memory.h>
  1580. + #include <unistd.h>
  1581. + #ifdef __GNUC__
  1582. + #define alloca __builtin_alloca
  1583. + #endif
  1584.   
  1585.   static char *logname = NULL;
  1586.   
  1587. *** 1.8    1992/04/19 16:02:45
  1588. --- getopt.c    1992/06/03 14:49:19
  1589. ***************
  1590. *** 14,27 ****
  1591.   #include     <stddef.h>
  1592.   #include    <stdio.h>
  1593.   #include    <string.h>
  1594. - #include     <unistd.h>
  1595.   
  1596.   int    opterr = 1;            /* error => print message */
  1597.   int    optind = 1;            /* next argv[] index */
  1598.   char    *optarg = NULL;            /* option parameter if any */
  1599.   
  1600. - static char mtail[] = " -- x\n";
  1601.   static int
  1602.   Err( name, mess, c )            /* returns '?' */
  1603.       char    *name;            /* program name argv[0] */
  1604. --- 14,24 ----
  1605. ***************
  1606. *** 29,41 ****
  1607.       int    c;            /* defective option letter */
  1608.       {
  1609.       if ( opterr )
  1610. !         {
  1611. !             mtail[4] = (char)c;
  1612. !             (void) fputs(name, stderr);
  1613. !             (void) fputs(": ", stderr);
  1614. !             (void) fputs(mess, stderr);
  1615. !             (void) fputs(&mtail[0], stderr);
  1616. !         }
  1617.       return '?';            /* erroneous-option marker */
  1618.       }
  1619.   
  1620. --- 26,36 ----
  1621.       int    c;            /* defective option letter */
  1622.       {
  1623.       if ( opterr )
  1624. !         (void) fprintf( stderr,
  1625. !                 "%s: %s -- %c\n",
  1626. !                 name, mess, c
  1627. !                   );
  1628.       return '?';            /* erroneous-option marker */
  1629.       }
  1630.   
  1631. ***************
  1632. *** 42,48 ****
  1633.   int
  1634.   getopt( argc, argv, optstring )        /* returns letter, '?', EOF */
  1635.       int        argc;        /* argument count from main */
  1636. !     char *const     *argv;        /* argument vector from main */
  1637.       const char    *optstring;    /* allowed args, e.g. "ab:c" */
  1638.       {
  1639.       static int    sp = 1;        /* position within argument */
  1640. --- 37,43 ----
  1641.   int
  1642.   getopt( argc, argv, optstring )        /* returns letter, '?', EOF */
  1643.       int        argc;        /* argument count from main */
  1644. !         const char      *argv[];        /* argument vector from main */
  1645.       const char    *optstring;    /* allowed args, e.g. "ab:c" */
  1646.       {
  1647.       static int    sp = 1;        /* position within argument */
  1648. *** 1.4    1991/04/12 18:19:53
  1649. --- getpid.c    1992/06/03 14:49:19
  1650. ***************
  1651. *** 1,19 ****
  1652. ! /* from Dale Schumacher's dLibs library */
  1653.   #include <unistd.h>
  1654.   #include <basepage.h>
  1655.   
  1656. ! int getpid()
  1657. !     {
  1658. !     register unsigned long n;
  1659.   
  1660. !     n = (unsigned long) _base;    /* load process base address */
  1661. !     return(0x7FFF & (n >> 8));    /* create unique pid from it */
  1662. !     }
  1663. ! int getppid()
  1664. !     {
  1665. !     register unsigned long n;
  1666. !     n = (unsigned long) _base->p_parent; /* load parents base address */
  1667. !       return(0x7FFF & (n >> 8));    /* create unique pid from it */
  1668. !       }
  1669. --- 1,9 ----
  1670. ! #include <osbind.h>
  1671.   #include <unistd.h>
  1672.   #include <basepage.h>
  1673. + #include "mintbind.h"
  1674.   
  1675. ! extern int __mint;
  1676.   
  1677. ! int getpid() { return __mint ? Pgetpid() : ( ((long)_base) >> 8 ); }
  1678. ! int getppid() { return __mint ? Pgetppid() : (((long)(_base->p_parent)) >> 8); }
  1679. *** 1.9    1992/01/29 20:58:29
  1680. --- getpw.c    1992/06/03 14:49:20
  1681. ***************
  1682. *** 29,41 ****
  1683.   arnold@emoryu1.{CSNET, UUCP, ARPA, BITNET}
  1684.   */
  1685.   
  1686.   #include <stdio.h>
  1687. - #include <types.h>
  1688.   #include <pwd.h>
  1689.   #include <unistd.h>
  1690. - #include <support.h>
  1691. - #include <stdlib.h>
  1692.   #include <string.h>
  1693.   
  1694.   static char *pwdfile = "/etc/passwd";    /* default passwd file */
  1695.   
  1696. --- 29,41 ----
  1697.   arnold@emoryu1.{CSNET, UUCP, ARPA, BITNET}
  1698.   */
  1699.   
  1700. + /* minorly customized by ERS for the MiNT library */
  1701.   #include <stdio.h>
  1702.   #include <pwd.h>
  1703.   #include <unistd.h>
  1704.   #include <string.h>
  1705. + #include <stdlib.h>
  1706.   
  1707.   static char *pwdfile = "/etc/passwd";    /* default passwd file */
  1708.   
  1709. ***************
  1710. *** 42,48 ****
  1711.   static FILE *fp = NULL;
  1712.   static struct passwd curentry;        /* static data to return */
  1713.   
  1714. ! static int nextent(void);
  1715.   
  1716.   void setpwfile (cp)
  1717.   char *cp;
  1718. --- 42,48 ----
  1719.   static FILE *fp = NULL;
  1720.   static struct passwd curentry;        /* static data to return */
  1721.   
  1722. ! static int nextent __PROTO((void));
  1723.   
  1724.   void setpwfile (cp)
  1725.   char *cp;
  1726. ***************
  1727. *** 51,57 ****
  1728.       if(cp) pwdfile = cp;
  1729.   }
  1730.   
  1731. ! int setpwent ()
  1732.   {
  1733.       if (fp)
  1734.           rewind (fp);
  1735. --- 51,57 ----
  1736.       if(cp) pwdfile = cp;
  1737.   }
  1738.   
  1739. ! void setpwent ()
  1740.   {
  1741.       if (fp)
  1742.           rewind (fp);
  1743. ***************
  1744. *** 65,76 ****
  1745.           fprintf (stderr,
  1746.               "setpwent: %s non-existant or unreadable.\n", pwdfile);
  1747.   #endif
  1748. -         return (0);
  1749.       }
  1750. -     return (1);
  1751.   }
  1752.   
  1753. ! int endpwent ()
  1754.   {
  1755.       if (fp)
  1756.       {
  1757. --- 65,74 ----
  1758.           fprintf (stderr,
  1759.               "setpwent: %s non-existant or unreadable.\n", pwdfile);
  1760.   #endif
  1761.       }
  1762.   }
  1763.   
  1764. ! void endpwent ()
  1765.   {
  1766.       if (fp)
  1767.       {
  1768. ***************
  1769. *** 77,89 ****
  1770.           fclose (fp);
  1771.           fp = NULL;
  1772.       }
  1773. -     return 1;
  1774.   }
  1775.   
  1776.   struct passwd *getpwent ()
  1777.   {
  1778. !     if (! fp && ! setpwent ())
  1779. !         return (NULL);
  1780.   
  1781.       if (! nextent ())
  1782.           return (NULL);
  1783. --- 75,89 ----
  1784.           fclose (fp);
  1785.           fp = NULL;
  1786.       }
  1787.   }
  1788.   
  1789.   struct passwd *getpwent ()
  1790.   {
  1791. !     if (! fp ) {
  1792. !         setpwent();
  1793. !         if (! fp )
  1794. !             return (NULL);
  1795. !     }
  1796.   
  1797.       if (! nextent ())
  1798.           return (NULL);
  1799. ***************
  1800. *** 91,106 ****
  1801.           return (& curentry);
  1802.   }
  1803.   
  1804. - #if __STDC__
  1805. - struct passwd *getpwuid (uid_t uid)
  1806. - #else
  1807.   struct passwd *getpwuid (uid)
  1808. ! uid_t uid;
  1809. ! #endif
  1810.   {
  1811. !     if (! setpwent ())
  1812. !         return (NULL);
  1813.       while (nextent ())
  1814.           if (curentry.pw_uid == uid)
  1815.               return (& curentry);
  1816. --- 91,100 ----
  1817.           return (& curentry);
  1818.   }
  1819.   
  1820.   struct passwd *getpwuid (uid)
  1821. ! register int uid;
  1822.   {
  1823. !     setpwent ();
  1824.       while (nextent ())
  1825.           if (curentry.pw_uid == uid)
  1826.               return (& curentry);
  1827. ***************
  1828. *** 111,118 ****
  1829.   struct passwd *getpwnam (name)
  1830.   register const char *name;
  1831.   {
  1832. !     if (! setpwent ())
  1833. !         return (NULL);
  1834.   
  1835.       while (nextent ())
  1836.           if (strcmp (curentry.pw_name, name) == 0)
  1837. --- 105,111 ----
  1838.   struct passwd *getpwnam (name)
  1839.   register const char *name;
  1840.   {
  1841. !     setpwent ();
  1842.   
  1843.       while (nextent ())
  1844.           if (strcmp (curentry.pw_name, name) == 0)
  1845. ***************
  1846. *** 121,134 ****
  1847.       return (NULL);
  1848.   }
  1849.   
  1850.   static char savbuf[BUFSIZ];
  1851.           
  1852.   static int nextent ()
  1853.   {
  1854.       register char *cp;
  1855.   
  1856. !     if (! fp && ! setpwent ())
  1857. !         return (0);
  1858.   
  1859.       while (fgets (savbuf, sizeof(savbuf), fp) != NULL)
  1860.       {
  1861. --- 114,134 ----
  1862.       return (NULL);
  1863.   }
  1864.   
  1865. + #ifdef atarist
  1866. + static char savbuf[256];    /* BUFSIZ seems bigger than necessary! */
  1867. + #else
  1868.   static char savbuf[BUFSIZ];
  1869. + #endif
  1870.           
  1871.   static int nextent ()
  1872.   {
  1873.       register char *cp;
  1874.   
  1875. !     if (! fp ) {
  1876. !         setpwent ();
  1877. !         if (! fp )
  1878. !             return (0);
  1879. !     }
  1880.   
  1881.       while (fgets (savbuf, sizeof(savbuf), fp) != NULL)
  1882.       {
  1883. *** 1.6    1992/04/13 15:50:45
  1884. --- getuid.c    1992/06/03 14:49:20
  1885. ***************
  1886. *** 1,26 ****
  1887. ! /* fake UNIX getuid, setuid, etc. calls.
  1888. !    In fact, all we can do is pretend.
  1889. !    By ERS
  1890. ! */
  1891.   #include <unistd.h>
  1892. ! /* pretending we are root (0,0) is probably not a good idea */
  1893. ! static uid_t euid = 1, uid = 1;
  1894. ! static gid_t egid = 1, gid = 1;
  1895. !   
  1896. ! uid_t getuid() { return uid; }
  1897. ! uid_t geteuid(){ return euid; }
  1898. ! gid_t getgid() { return gid; }
  1899. ! gid_t getegid() { return egid; }
  1900. ! uid_t setuid(x) int x; { return uid = x; }
  1901. ! gid_t setgid(x) int x; { return gid = x; }
  1902. ! uid_t seteuid(x) int x; { return euid = x; }
  1903. ! gid_t setegid(x) int x; { return egid = x; }
  1904. !   
  1905. ! int setpgrp() { return getpid(); }
  1906. ! int getpgrp() { return getpid(); }
  1907.   
  1908. --- 1,73 ----
  1909. ! #include <sys/types.h>
  1910.   #include <unistd.h>
  1911. ! #include <osbind.h>
  1912. ! #include <mintbind.h>
  1913. ! #include <errno.h>
  1914. ! extern int __mint;
  1915. ! static int __uid = 1, __gid = 1;
  1916. ! uid_t getuid() { return __mint ? Pgetuid() : __uid; }
  1917. ! gid_t getgid() { return __mint ? Pgetgid() : __gid; }
  1918. ! uid_t geteuid() { return getuid(); }
  1919. ! gid_t getegid() { return getgid(); }
  1920. ! int setuid(x)
  1921. !     int x;
  1922. ! {
  1923. !     long r;
  1924. !     if (__mint) {
  1925. !         r = Psetuid(x);
  1926. !         if (r) {
  1927. !             errno = -r;
  1928. !             return -1;
  1929. !         }
  1930. !         return 0;
  1931. !     }
  1932. !     __uid = x;
  1933. !     return 0;
  1934. ! }
  1935. ! int setgid(x)
  1936. !     int x;
  1937. ! {
  1938. !     long r;
  1939. !     if (__mint) {
  1940. !         r = Psetgid(x);
  1941. !         if (r) {
  1942. !             errno = -r;
  1943. !             return -1;
  1944. !         }
  1945. !         return 0;
  1946. !     }
  1947. !     __gid = x;
  1948. !     return 0;
  1949. ! }
  1950. ! int setreuid(ruid,euid)
  1951. !     int ruid, euid;
  1952. ! {
  1953. !     return setuid(euid);
  1954. ! }
  1955. ! int setregid(rgid,egid)
  1956. !     int rgid, egid;
  1957. ! {
  1958. !     return setgid(egid);
  1959. ! }
  1960. ! /* note: BSD getpgrp takes an argument, but ours doesn't */
  1961. ! int getpgrp() { return __mint ? Pgetpgrp() : 0; }
  1962. ! int setpgrp(pid, grp)
  1963. !     int pid, grp;
  1964. ! {
  1965. !     return __mint ? Psetpgrp(pid, grp) : 0;
  1966. ! }
  1967.   
  1968. + int seteuid(x) int x; { return setuid(x); }
  1969. + int setegid(x) int x; { return setgid(x); }
  1970. *** 1.8    1992/04/06 19:33:32
  1971. --- gmon.c    1992/06/03 14:49:20
  1972. ***************
  1973. *** 16,21 ****
  1974. --- 16,22 ----
  1975.   #include <basepage.h>
  1976.   #include <sysvars.h>
  1977.   #include <xbra.h>
  1978. + #include <string.h>
  1979.   #ifndef _COMPILER_H
  1980.   #include <compiler.h>
  1981.   #endif
  1982. ***************
  1983. *** 617,623 ****
  1984.       ((unsigned long)Setexc(exc, -1L) - offsetof(xbra_struct, jump));
  1985.       if(this == me)
  1986.       {    /* at the head, just unlink */
  1987. !     Setexc(exc, me->next);
  1988.       return;
  1989.       }
  1990.       /* otherwise find me in the chain and unlink */
  1991. --- 618,624 ----
  1992.       ((unsigned long)Setexc(exc, -1L) - offsetof(xbra_struct, jump));
  1993.       if(this == me)
  1994.       {    /* at the head, just unlink */
  1995. !     (void)Setexc(exc, me->next);
  1996.       return;
  1997.       }
  1998.       /* otherwise find me in the chain and unlink */
  1999. ***************
  2000. *** 630,636 ****
  2001.       if(this->xbra_magic != _XBRA_MAGIC) 
  2002.       {    /* shame on you */
  2003.           Super(save_ssp);
  2004. !         Setexc(exc, me->next); /* nuke it, otherwise it may call ME */
  2005.           return;           /* after i am deinstalled */
  2006.       }
  2007.       }
  2008. --- 631,637 ----
  2009.       if(this->xbra_magic != _XBRA_MAGIC) 
  2010.       {    /* shame on you */
  2011.           Super(save_ssp);
  2012. !         (void)Setexc(exc, me->next); /* nuke it, otherwise it may call ME */
  2013.           return;           /* after i am deinstalled */
  2014.       }
  2015.       }
  2016. *** 1.4    1991/04/26 03:42:08
  2017. --- grp.c    1992/06/03 14:49:21
  2018. ***************
  2019. *** 1,47 ****
  2020.   /*
  2021. !  * faking of group id's. written by ERS; it's public domain, if
  2022. !  * you want it!
  2023.    */
  2024.   
  2025.   #include <string.h>
  2026.   #include <stdlib.h>
  2027.   #include <unistd.h>
  2028.   #include <grp.h>
  2029.   
  2030. ! __EXTERN char *    getlogin    __PROTO((void));
  2031.   
  2032. ! static char root_str[] = "root";
  2033. ! static char user_str[80];
  2034.   
  2035. ! static char *root_mem[] = { root_str, (char *)0 };
  2036. ! static char *user_mem[] = { root_str, user_str, (char *)0 };
  2037.   
  2038. ! static struct group root_group = { root_str, "", 0, root_mem };
  2039. ! static struct group user_group = { "user", "", 1, user_mem };
  2040.   
  2041. ! struct group *
  2042. ! getgrgid(gid)
  2043. !     int gid;
  2044.   {
  2045. !     if (gid == 0)
  2046. !         return &root_group;
  2047. !     else if (gid == 1) {
  2048. !         strcpy(user_str, getlogin());
  2049. !         return &user_group;
  2050.       }
  2051. -     else
  2052. -         return 0;
  2053.   }
  2054.   
  2055. ! struct group *
  2056. ! getgrnam(name)
  2057. !     char *name;
  2058. ! {
  2059. !     strcpy(user_str, getlogin());
  2060. !     if (!strcmp(name, root_str))
  2061. !         return &root_group;
  2062. !     else if (!strcmp(name, "user"))
  2063. !         return &user_group;
  2064.       else
  2065. !         return 0;
  2066.   }
  2067. --- 1,174 ----
  2068.   /*
  2069. !  * Routines for reading information from /etc/group.
  2070. !  * Written by Eric Smith, based on Arnold Robbins' public domain
  2071. !  * getpwent routines (see getpw.c).
  2072.    */
  2073.   
  2074. + #include <stdio.h>
  2075.   #include <string.h>
  2076.   #include <stdlib.h>
  2077.   #include <unistd.h>
  2078.   #include <grp.h>
  2079.   
  2080. ! static char *grpfile = "/etc/group";    /* default group file */
  2081. ! static FILE *fp;
  2082.   
  2083. ! static struct group curentry;        /* static data to return */
  2084.   
  2085. ! static int nextent __PROTO((void));
  2086.   
  2087. ! void setgrent ()
  2088. ! {
  2089. !     if (fp)
  2090. !         rewind (fp);
  2091. ! #ifdef atarist
  2092. !     else if ((fp = fopen (grpfile, "rt")) == NULL)
  2093. ! #else
  2094. !     else if ((fp = fopen (grpfile, "r")) == NULL)
  2095. ! #endif
  2096. !     {
  2097. ! #ifdef VERBOSE
  2098. !         fprintf (stderr,
  2099. !             "setgrent: %s non-existant or unreadable.\n", grpfile);
  2100. ! #endif
  2101. !     }
  2102. ! }
  2103.   
  2104. ! void endgrent ()
  2105.   {
  2106. !     if (fp)
  2107. !     {
  2108. !         fclose (fp);
  2109. !         fp = NULL;
  2110.       }
  2111.   }
  2112.   
  2113. ! struct group *getgrent ()
  2114. ! {
  2115. !     if (!fp) setgrent();
  2116. !     if (!fp) return NULL;
  2117. !     if (! nextent ())
  2118. !         return (NULL);
  2119.       else
  2120. !         return (& curentry);
  2121. ! }
  2122. ! struct group *getgrgid (gid)
  2123. !     int gid;
  2124. ! {
  2125. !     setgrent();
  2126. !     while (nextent ())
  2127. !         if (curentry.gr_gid == gid)
  2128. !             return (& curentry);
  2129. !     return (NULL);
  2130. ! }
  2131. ! struct group *getgrnam (name)
  2132. ! register char *name;
  2133. ! {
  2134. !     setgrent();
  2135. !     while (nextent ())
  2136. !         if (strcmp (curentry.gr_name, name) == 0)
  2137. !             return (& curentry);
  2138. !     return (NULL);
  2139. ! }
  2140. ! #define MAX_MEMBERS 128        /* max. number of members in a group */
  2141. ! static char savbuf[512];
  2142. ! static char *memb[MAX_MEMBERS];
  2143. ! static int nextent ()
  2144. ! {
  2145. !     register char *cp;
  2146. !     register int i;
  2147. !     if (!fp) setgrent();
  2148. !     if (!fp) return 0;
  2149. !     if (fgets (savbuf, sizeof(savbuf), fp) != NULL)
  2150. !     {
  2151. !         for (cp = savbuf; *cp && *cp != ':'; cp++)
  2152. !             ;
  2153. !         curentry.gr_name = savbuf;
  2154. !         *cp++ = '\0';
  2155. !         curentry.gr_passwd = cp;
  2156. !         for (; *cp && *cp != ':'; cp++)
  2157. !             ;
  2158. !         *cp++ = '\0';
  2159. !         curentry.gr_gid = atoi (cp);
  2160. !         for (; *cp && *cp != ':'; cp++)
  2161. !             ;
  2162. !         *cp++ = '\0';
  2163. !         i = 0;
  2164. !         while( *cp ) {
  2165. !             if (i >= MAX_MEMBERS-1) break;
  2166. !             memb[i++] = cp;
  2167. !             for(; *cp && *cp != ',' && *cp != '\n'; cp++)
  2168. !                 ;
  2169. !             if (*cp == '\n')
  2170. !                 *cp = 0;
  2171. !             else if (*cp)
  2172. !                 *cp++ = 0;
  2173. !         }
  2174. !         memb[i] = NULL;
  2175. !         curentry.gr_mem = memb;
  2176. !         return (1);
  2177. !     }
  2178. !     return (0);
  2179. ! }
  2180. ! #ifdef TEST
  2181. ! int
  2182. ! main (argc, argv)
  2183. ! int argc;
  2184. ! char **argv;
  2185. ! {
  2186. !     struct group *gr;
  2187. !     char **m;
  2188. !     if (argc > 1) {
  2189. !         grpfile = argv[1];
  2190. !     }
  2191. !     setgrent ();
  2192. !     while ((gr = getgrent ()) != NULL)
  2193. !     {
  2194. !         printf ("%s:[%s] %d\n",
  2195. !             gr->gr_name,
  2196. !             gr->gr_passwd,
  2197. !             gr->gr_gid);
  2198. !         for (m = gr->gr_mem; *m; m++) {
  2199. !             printf("\t%s\n", *m);
  2200. !         }
  2201. !     }
  2202. !     endgrent ();
  2203. !     if (gr = getgrnam ("mail")) {
  2204. !         printf ("%s:[%s] %d\n",
  2205. !             gr->gr_name,
  2206. !             gr->gr_passwd,
  2207. !             gr->gr_gid);
  2208. !         for (m = gr->gr_mem; *m; m++) {
  2209. !             printf("\t%s\n", *m);
  2210. !         }
  2211. !     }
  2212. !     if (gr = getgrgid (1)) {
  2213. !         printf ("%s:[%s] %d\n",
  2214. !             gr->gr_name,
  2215. !             gr->gr_passwd,
  2216. !             gr->gr_gid);
  2217. !         for (m = gr->gr_mem; *m; m++) {
  2218. !             printf("\t%s\n", *m);
  2219. !         }
  2220. !     }
  2221. !     return 0;
  2222.   }
  2223. + #endif
  2224. *** 1.5    1991/12/26 15:53:59
  2225. --- lib.h    1992/06/03 14:49:22
  2226. ***************
  2227. *** 8,13 ****
  2228. --- 8,14 ----
  2229.   #include <compiler.h>
  2230.   #endif
  2231.   
  2232. + #include <stdio.h>    /* for FILE   */
  2233.   #include <time.h>    /* for time_t */
  2234.   
  2235.   /* filename mapping function type */
  2236. ***************
  2237. *** 14,46 ****
  2238.   #ifndef __FNMAP
  2239.   #define __FNMAP
  2240.   #ifdef __STDC__
  2241. ! typedef void (*fnmapfunc_t)(const char *, char *);
  2242.   #else
  2243. ! typedef void (*fnmapfunc_t)();
  2244.   #endif
  2245.   #endif
  2246.   
  2247. ! int    _unx2dos __PROTO((const char *, char *));
  2248. ! int    _dos2unx __PROTO((const char *, char *));
  2249. ! int    unx2dos __PROTO((const char *, char *));
  2250. ! int    dos2unx __PROTO((const char *, char *));
  2251. ! int    spawnve __PROTO((int, char *, char **, char **));
  2252. ! int    console_input_status __PROTO((int));
  2253. ! unsigned int    console_read_byte __PROTO((int));
  2254. ! void        console_write_byte __PROTO((int, int));
  2255. ! int        dos2unx __PROTO((const char *, char *));
  2256. ! time_t        dostime __PROTO((time_t));
  2257. ! char *        findfile __PROTO((char *, char *, char **));
  2258. ! char *        _itoa __PROTO((int, char *, int));
  2259. ! char *        _ltoa __PROTO((long, char *, int));
  2260. ! char *        _ultoa __PROTO((unsigned long, char *, int));
  2261. ! time_t        unixtime __PROTO((unsigned int, unsigned int));
  2262. ! int        unx2dos __PROTO((const char *, char *));
  2263. ! void        fnmapfunc __PROTO((fnmapfunc_t u2dos, fnmapfunc_t dos2u));
  2264. ! long        get_sysvar __PROTO((void *var));
  2265. ! void        set_sysvar_to_long __PROTO((void *var, long val));
  2266.   
  2267. ! __EXTERN __EXITING __exit __PROTO((long status));
  2268. ! __EXTERN char *_itoa __PROTO((int, char *, int));
  2269.   
  2270.   #endif /* _LIB_H */
  2271. --- 15,71 ----
  2272.   #ifndef __FNMAP
  2273.   #define __FNMAP
  2274.   #ifdef __STDC__
  2275. ! typedef int (*fnmapfunc_t)(const char *, char *);
  2276.   #else
  2277. ! typedef int (*fnmapfunc_t)();
  2278.   #endif
  2279.   #endif
  2280.   
  2281. ! __EXTERN int        _unx2dos __PROTO((const char *, char *));
  2282. ! __EXTERN int        _dos2unx __PROTO((const char *, char *));
  2283. ! __EXTERN int        unx2dos __PROTO((const char *, char *));
  2284. ! __EXTERN int        dos2unx __PROTO((const char *, char *));
  2285. ! __EXTERN void        fnmapfunc __PROTO((fnmapfunc_t u2dos, fnmapfunc_t dos2u));
  2286.   
  2287. ! __EXTERN int        spawnve __PROTO((int, char *, char **, char **));
  2288. ! __EXTERN long        _write      __PROTO((int, const void *, unsigned long));
  2289. ! __EXTERN long        _read      __PROTO((int, void *, unsigned long));
  2290. ! __EXTERN int        console_input_status __PROTO((int));
  2291. ! __EXTERN unsigned int    console_read_byte __PROTO((int));
  2292. ! __EXTERN void        console_write_byte __PROTO((int, int));
  2293. ! __EXTERN time_t        dostime __PROTO((time_t));
  2294. ! __EXTERN time_t        _unixtime __PROTO((unsigned int, unsigned int));
  2295. ! __EXTERN char *        findfile __PROTO((char *, char *, char **));
  2296. ! __EXTERN char *        _itoa __PROTO((int, char *, int));
  2297. ! __EXTERN char *        _ltoa __PROTO((long, char *, int));
  2298. ! __EXTERN char *        _ultoa __PROTO((unsigned long, char *, int));
  2299. ! __EXTERN int        _doprnt __PROTO((FILE *, const char *, __VA_LIST__));
  2300. ! __EXTERN long        get_sysvar __PROTO((void *var));
  2301. ! __EXTERN void        set_sysvar_to_long __PROTO((void *var, long val));
  2302. ! __EXTERN __EXITING     __exit __PROTO((long status));
  2303. ! /* from the TOS GCC library */
  2304. ! /* 5/5/92 sb -- definitions needed in malloc.c and realloc.c */
  2305. ! struct mem_chunk 
  2306. !     {
  2307. !     long valid;
  2308. ! #define VAL_FREE  0xf4ee0abc
  2309. ! #define VAL_ALLOC 0xa11c0abc
  2310. !     struct mem_chunk *next;
  2311. !     unsigned long size;
  2312. !     };
  2313. ! /* linked list of free blocks */
  2314. ! __EXTERN struct mem_chunk _mchunk_free_list;
  2315.   
  2316.   #endif /* _LIB_H */
  2317. *** 1.13    1992/01/29 20:58:29
  2318. --- localtim.c    1992/06/03 14:49:22
  2319. ***************
  2320. *** 39,45 ****
  2321.   mth_start[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
  2322.   
  2323.   static time_t tzoffset __PROTO((char *s, int *hasdst));
  2324. ! static int indst __PROTO((const struct tm *t));
  2325.   
  2326.   static int dst = -1;    /* whether dst holds in current timezone */
  2327.   
  2328. --- 39,45 ----
  2329.   mth_start[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
  2330.   
  2331.   static time_t tzoffset __PROTO((char *s, int *hasdst));
  2332. ! static int indst __PROTO((long secs, const struct tm *t));
  2333.   
  2334.   static int dst = -1;    /* whether dst holds in current timezone */
  2335.   
  2336. ***************
  2337. *** 54,61 ****
  2338.    *  returned by localtime() and convert it into the standard representation
  2339.    *  (as seconds since midnight Jan. 1 1970, GMT).
  2340.    *
  2341. !  * Note that time() sends us such a structure with tm_yday undefined, so
  2342. !  * we shouldn't count on tm_yday being correct.
  2343.    */
  2344.   
  2345.   time_t
  2346. --- 54,61 ----
  2347.    *  returned by localtime() and convert it into the standard representation
  2348.    *  (as seconds since midnight Jan. 1 1970, GMT).
  2349.    *
  2350. !  * Note that time() sends us such a structure with tm_yday and tm_wday
  2351. !  * undefined, so we shouldn't count on these being correct!
  2352.    */
  2353.   
  2354.   time_t
  2355. ***************
  2356. *** 82,89 ****
  2357.       tzset();
  2358.   
  2359.           s += _timezone;
  2360. !         if (dst == 1 && indst(t))
  2361. !                 s -= 3600;
  2362.   
  2363.           return s;
  2364.   }
  2365. --- 82,89 ----
  2366.       tzset();
  2367.   
  2368.           s += _timezone;
  2369. !         if (dst == 1 && indst(s, t))
  2370. !                 s -= SECS_PER_HOUR;
  2371.   
  2372.           return s;
  2373.   }
  2374. ***************
  2375. *** 148,163 ****
  2376.   {
  2377.       static struct tm ltim;
  2378.           struct tm *stm;
  2379. !         time_t offset;  /* seconds between local time and GMT */
  2380.   
  2381.       tzset();
  2382. !         offset = *t - _timezone;
  2383. !     if(offset < 0) offset = 0; /* this is questionable */
  2384. !         stm = _gmtime(&offset, <im);
  2385.       if (stm == NULL) return stm;        /* check for illegal time */
  2386.           stm->tm_isdst = (dst == -1) ? -1 : 0;
  2387.   
  2388. !         if (dst == 1 && indst((const struct tm *)stm)) {   /* daylight savings time in effect */
  2389.                   stm->tm_isdst = 1;
  2390.                   if (++stm->tm_hour > 23) {
  2391.                           stm->tm_hour -= 24;
  2392. --- 148,163 ----
  2393.   {
  2394.       static struct tm ltim;
  2395.           struct tm *stm;
  2396. !         time_t gmsecs;  /*time in GMT */ 
  2397.   
  2398.       tzset();
  2399. !         gmsecs = *t - _timezone;
  2400. !         stm = _gmtime(&gmsecs, <im);
  2401.       if (stm == NULL) return stm;        /* check for illegal time */
  2402.           stm->tm_isdst = (dst == -1) ? -1 : 0;
  2403.   
  2404. !         if (dst == 1 && indst(*t, (const struct tm *)stm)) {
  2405. !        /* daylight savings time in effect */
  2406.                   stm->tm_isdst = 1;
  2407.                   if (++stm->tm_hour > 23) {
  2408.                           stm->tm_hour -= 24;
  2409. ***************
  2410. *** 170,176 ****
  2411.                           }
  2412.                   }
  2413.           }
  2414. ! DEBUG_TM("localtime", stm);
  2415.           return stm;
  2416.   }
  2417.   
  2418. --- 170,176 ----
  2419.                           }
  2420.                   }
  2421.           }
  2422. !     DEBUG_TM("localtime", stm);
  2423.           return stm;
  2424.   }
  2425.   
  2426. ***************
  2427. *** 302,310 ****
  2428.    */
  2429.   
  2430.   static
  2431. ! int indst(t)
  2432.           const struct tm *t;
  2433.   {
  2434.           if (t->tm_mon == 3) {           /* April */
  2435.   /* before 1987, see if there's another sunday in the month */
  2436.                   if (t->tm_year < 87 && t->tm_wday + 30 - t->tm_mday < 7)
  2437. --- 302,318 ----
  2438.    */
  2439.   
  2440.   static
  2441. ! int indst(s, t)
  2442. !     long s;
  2443.           const struct tm *t;
  2444.   {
  2445. +     int wkday;
  2446. +     if (t->tm_wday >= 0)
  2447. +         wkday = t->tm_wday;
  2448. +     else
  2449. +         wkday = ((s / SECS_PER_DAY) + 4) % 7;
  2450.           if (t->tm_mon == 3) {           /* April */
  2451.   /* before 1987, see if there's another sunday in the month */
  2452.                   if (t->tm_year < 87 && t->tm_wday + 30 - t->tm_mday < 7)
  2453. *** 1.7    1992/03/22 21:57:30
  2454. --- lseek.c    1992/06/03 14:49:22
  2455. ***************
  2456. *** 2,17 ****
  2457.   #include <stdio.h>
  2458.   #include <errno.h>
  2459.   #include <osbind.h>
  2460. - #include <unistd.h>
  2461.   #include <memory.h>
  2462.   #include <string.h>
  2463.   #include "lib.h"
  2464. - #ifndef _COMPILER_H
  2465. - #include <compiler.h>
  2466. - #endif
  2467.   
  2468. ! static long _real_lseek __PROTO((int h, long where, int how));
  2469.   
  2470.   static long _real_lseek(h, where, how)
  2471.   int h;
  2472. --- 2,17 ----
  2473.   #include <stdio.h>
  2474.   #include <errno.h>
  2475.   #include <osbind.h>
  2476.   #include <memory.h>
  2477.   #include <string.h>
  2478. + #include <unistd.h>
  2479.   #include "lib.h"
  2480.   
  2481. ! #ifdef __GNUC__
  2482. ! #  ifndef alloca
  2483. ! #    define alloca __builtin_alloca
  2484. ! #  endif
  2485. ! #endif
  2486.   
  2487.   static long _real_lseek(h, where, how)
  2488.   int h;
  2489. ***************
  2490. *** 67,73 ****
  2491.           offset = 256;
  2492.       if((current_pos = _write(handle, buf, offset)) != offset)
  2493.           return((current_pos > 0) ? (new_pos + current_pos) :
  2494. !            new_pos);    /* errno set by _write */
  2495.       new_pos += offset;
  2496.       }
  2497.       return(new_pos);  
  2498. --- 67,73 ----
  2499.           offset = 256;
  2500.       if((current_pos = _write(handle, buf, offset)) != offset)
  2501.           return((current_pos > 0) ? (new_pos + current_pos) :
  2502. !            new_pos);    /* errno set by write */
  2503.       new_pos += offset;
  2504.       }
  2505.       return(new_pos);  
  2506. *** 1.6    1991/04/26 03:42:08
  2507. --- ltoa.c    1992/06/03 14:49:23
  2508. ***************
  2509. *** 1,4 ****
  2510. --- 1,5 ----
  2511.   #include <string.h>
  2512. + #include "lib.h"
  2513.   
  2514.   #ifdef __STRICT_ANSI__
  2515.   #  ifdef __GNUC__
  2516. *** 1.20    1992/03/06 19:19:47
  2517. --- malloc.c    1992/06/03 14:49:23
  2518. ***************
  2519. *** 2,13 ****
  2520. --- 2,17 ----
  2521.   /* malloc, free, realloc: dynamic memory allocation */
  2522.   /* ERS: added mlalloc, relalloc, etc. for 16 bit compilers. Changed
  2523.      argument of malloc, etc.,  to size_t (per ANSI draft). */
  2524. + /* 5/2/92 sb -- modified for Heat-n-Serve C to accomodate its 16-bit size_t */
  2525. + /* 5/5/92 sb -- split off realloc() & calloc() to reduce library drag */
  2526.   
  2527.   #include <stddef.h>    /* for size_t */
  2528. + #include <stdlib.h>
  2529.   #include <memory.h>
  2530.   #include <string.h>
  2531.   #include <assert.h>
  2532.   #include <unistd.h>
  2533. + #include "lib.h"
  2534.   
  2535.   extern long _stksize;
  2536.   
  2537. ***************
  2538. *** 20,47 ****
  2539.               gets screwed on a 1M machine otherwise (stack/heap clash)
  2540.        */
  2541.   
  2542. ! struct mem_chunk 
  2543. !     {
  2544. !     long valid;
  2545. ! #define VAL_FREE  0xf4ee0abc
  2546. ! #define VAL_ALLOC 0xa11c0abc
  2547. !     struct mem_chunk *next;
  2548. !     long size;
  2549. !     };
  2550.   
  2551. ! /* linked list of free blocks */
  2552.   
  2553. - static struct mem_chunk _mchunk_free_list = { VAL_FREE, NULL, 0L };
  2554.   /* flag to control zero'ing of malloc'ed chunks */
  2555.   static int _ZeroMallocs = 0;
  2556.   
  2557.   
  2558. ! asm(".stabs \"_mlalloc\",5,0,0,_malloc"); /* dept of clean tricks */
  2559.   
  2560. ! void * malloc(n)
  2561. ! size_t n; 
  2562.   {
  2563.     struct mem_chunk *p, *q;
  2564.     long sz;
  2565. --- 24,45 ----
  2566.               gets screwed on a 1M machine otherwise (stack/heap clash)
  2567.        */
  2568.   
  2569. ! /* linked list of free blocks struct defined in lib.h */
  2570.   
  2571. ! struct mem_chunk _mchunk_free_list = { VAL_FREE, NULL, 0L };
  2572.   
  2573.   /* flag to control zero'ing of malloc'ed chunks */
  2574.   static int _ZeroMallocs = 0;
  2575.   
  2576. + __EXTERN void _bzero __PROTO((void *, unsigned long));
  2577. + __EXTERN void *_sbrk __PROTO((long));
  2578.   
  2579. ! #ifdef __GNUC__
  2580. ! asm(".stabs \"_malloc\",5,0,0,__malloc"); /* dept of clean tricks */
  2581. ! #endif
  2582.   
  2583. ! void * _malloc(n)
  2584. ! unsigned long n; 
  2585.   {
  2586.     struct mem_chunk *p, *q;
  2587.     long sz;
  2588. ***************
  2589. *** 71,77 ****
  2590.           if (MINHUNK < MAXHUNK)
  2591.               MINHUNK *= 2;
  2592.       }
  2593. !     q = (struct mem_chunk * )sbrk(sz);
  2594.   
  2595.       if (((long)q) == -1)         /* can't alloc any more? */
  2596.           return(NULL);
  2597. --- 69,75 ----
  2598.           if (MINHUNK < MAXHUNK)
  2599.               MINHUNK *= 2;
  2600.       }
  2601. !     q = (struct mem_chunk * )_sbrk(sz);
  2602.   
  2603.       if (((long)q) == -1)         /* can't alloc any more? */
  2604.           return(NULL);
  2605. ***************
  2606. *** 102,108 ****
  2607.     q->next = NULL;    
  2608.     q++;    /* hand back ptr to after chunk desc */
  2609.     if(_ZeroMallocs != 0)
  2610. !       bzero((void *)q, (long)(n - sizeof(struct mem_chunk)));
  2611.     
  2612.     return((void * )q);
  2613.   }
  2614. --- 100,106 ----
  2615.     q->next = NULL;    
  2616.     q++;    /* hand back ptr to after chunk desc */
  2617.     if(_ZeroMallocs != 0)
  2618. !       _bzero((void *)q, (long)(n - sizeof(struct mem_chunk)));
  2619.     
  2620.     return((void * )q);
  2621.   }
  2622. ***************
  2623. *** 184,272 ****
  2624.       }
  2625.   }
  2626.   
  2627. - asm(".stabs \"_relalloc\",5,0,0,_realloc");
  2628. - void * realloc(_r, n)
  2629. - void *_r;
  2630. - size_t n;
  2631. - {
  2632. -   struct mem_chunk *p, *q, *r = (struct mem_chunk *) _r;
  2633. -   long sz;
  2634. - /* obscure features: realloc(NULL,n) is the same as malloc(n)
  2635. -  *               realloc(p, 0) is the same as free(p)
  2636. -  */
  2637. -   if (!r)
  2638. -     return malloc(n);
  2639. -   if (n == 0) {
  2640. -     free(_r);
  2641. -     return NULL;
  2642. -   }
  2643. -   p = r - 1;
  2644. -   sz = (n + sizeof(struct mem_chunk) + 7) & ~7;
  2645. -   if (p->size > sz) 
  2646. -     {            /* block too big, split in two */
  2647. -     q = (struct mem_chunk * )(((long) p) + sz);
  2648. -     q->size = p->size - sz;
  2649. -         q->valid = VAL_ALLOC;
  2650. -     free(q + 1);
  2651. -     p->size = sz;
  2652. -     }
  2653. -     else 
  2654. -   if (p->size < sz)
  2655. -     {            /* block too small, get new one */
  2656. -     struct mem_chunk *s, *t;
  2657. -     q = &_mchunk_free_list;
  2658. -     t = _mchunk_free_list.next;
  2659. -     while (t != NULL && t < p)
  2660. -       {
  2661. -       q = t;
  2662. -       t = t->next;
  2663. -       }
  2664. -     /* merge after if possible */
  2665. -     s = (struct mem_chunk * )(((long) p) + p->size);
  2666. -     if (t != NULL && s >= t && p->size + t->size >= sz)
  2667. -       {
  2668. -       assert(s == t);
  2669. -       p->size += t->size;
  2670. -       q->next = t->next;
  2671. -       t->size = 0;
  2672. -       t->next = NULL;
  2673. -       }
  2674. -     else
  2675. -       {
  2676. -       q = (struct mem_chunk * )malloc(n);
  2677. -       if (q != NULL)
  2678. -     {
  2679. -     n = p->size - sizeof(struct mem_chunk);
  2680. -     bcopy(r, q, n);
  2681. -         free(r);    /* free r only if we got a new block */
  2682. -         }
  2683. -       /* else we could try to mlalloc the rest and hope that we can merge */
  2684. -       r = q;
  2685. -     }
  2686. -   }
  2687. -   /* else current block will do just fine */
  2688. -   return((void * )r);
  2689. - }
  2690. - asm(".stabs \"_clalloc\",5,0,0,_calloc");
  2691. - void * calloc(n, sz)
  2692. - size_t n, sz;
  2693. - {
  2694. -   void *r;
  2695. -   size_t total;
  2696. -   total = n * sz;
  2697. -   if ((r = malloc(total)) != NULL)
  2698. -     {
  2699. -      bzero(r, total);
  2700. -     }
  2701. -   return(r);
  2702. - }
  2703.   /*
  2704.    * Set zero block after malloc flag
  2705.    */
  2706. --- 182,187 ----
  2707. ***************
  2708. *** 284,286 ****
  2709. --- 199,209 ----
  2710.   {
  2711.       MAXHUNK = MINHUNK = siz;
  2712.   }
  2713. + #ifndef __GNUC__
  2714. + void * malloc(n)
  2715. + size_t n; 
  2716. + {
  2717. +   return _malloc((unsigned long) n);
  2718. + }
  2719. + #endif
  2720. *** 1.12    1992/03/10 15:11:47
  2721. --- mktemp.c    1992/06/03 14:49:23
  2722. ***************
  2723. *** 11,18 ****
  2724.   #include <errno.h>
  2725.   #include "lib.h"
  2726.   
  2727. - #define __MINT__
  2728. - #include <mintbind.h>
  2729.   extern int __mint;        /* 0 for TOS, MiNT version number otherwise */
  2730.   
  2731.   #define TEN_MUL(X)    ((((X) << 2) + (X)) << 1)
  2732. --- 11,16 ----
  2733. ***************
  2734. *** 38,45 ****
  2735.     /* we need 5 X's for this: up to 3 for the pid, and up to 2 for the
  2736.        extra number */
  2737.     if (__mint && nx > 4 && startat < 256) {
  2738. !     int pid = Pgetpid();
  2739. !     (void) _itoa(pid, q, 10);
  2740.       while (*q) q++;
  2741.       (void) _itoa(startat++, q, 16);
  2742.       return pattern;
  2743. --- 36,42 ----
  2744.     /* we need 5 X's for this: up to 3 for the pid, and up to 2 for the
  2745.        extra number */
  2746.     if (__mint && nx > 4 && startat < 256) {
  2747. !     (void) _itoa(getpid(), q, 10);
  2748.       while (*q) q++;
  2749.       (void) _itoa(startat++, q, 16);
  2750.       return pattern;
  2751. *** 1.8    1991/06/11 14:56:53
  2752. --- perror.c    1992/06/03 14:49:24
  2753. ***************
  2754. *** 8,106 ****
  2755.   #include <errno.h>
  2756.   #include <string.h>
  2757.   
  2758. - static char nullstr[] = "";
  2759. - char *sys_errlist[] =
  2760. -     {
  2761. -     "OK",                    /* 0 */
  2762. -     "error",                /* 1 */
  2763. -     "drive not ready",            /* 2 */
  2764. -     "unknown command",            /* 3 */
  2765. -     "crc error",                /* 4 */
  2766. -     "bad request",                /* 5 */
  2767. -     "seek error",                /* 6 */
  2768. -     "unknown media",            /* 7 */
  2769. -     "sector not found",            /* 8 */
  2770. -     "out of paper",                /* 9 */
  2771. -     "write failure",            /* 10 */
  2772. -     "read failure",                /* 11 */
  2773. -     "general mishap",                /* 12 */
  2774. -     "media write protected",        /* 13 */
  2775. -     "media changed",            /* 14 */
  2776. -     "unknown device",            /* 15 */
  2777. -     "bad sectors on format",        /* 16 */
  2778. -     "disk swap request",            /* 17 */
  2779. -     nullstr,                /* 18 */
  2780. -     nullstr,                /* 19 */
  2781. -     nullstr,                /* 20 */
  2782. -     nullstr,                /* 21 */
  2783. -     nullstr,                /* 22 */
  2784. -     nullstr,                /* 23 */
  2785. -     nullstr,                /* 24 */
  2786. -     nullstr,                /* 25 */
  2787. -     nullstr,                /* 26 */
  2788. -     nullstr,                /* 27 */
  2789. -     nullstr,                /* 28 */
  2790. -     nullstr,                /* 29 */
  2791. -     nullstr,                /* 30 */
  2792. -     nullstr,                /* 31 */
  2793. -     "invalid function number",        /* 32 */
  2794. -     "file not found",            /* 33 */
  2795. -     "path not found",            /* 34 */
  2796. -     "no more handles",            /* 35 */
  2797. -     "access denied",            /* 36 */
  2798. -     "invalid handle",            /* 37 */
  2799. -     nullstr,                /* 38 */
  2800. -     "out of memory",            /* 39 */
  2801. -     "invalid memory block",            /* 40 */
  2802. -     nullstr,                /* 41 */
  2803. -     nullstr,                /* 42 */
  2804. -     nullstr,                /* 43 */
  2805. -     nullstr,                /* 44 */
  2806. -     nullstr,                /* 45 */
  2807. -     "invalid drive id",            /* 46 */
  2808. -     nullstr,                /* 47 */
  2809. -     "rename across drives",            /* 48 */
  2810. -     "no more files",            /* 49 */
  2811. -     nullstr,                /* 50 */
  2812. -     nullstr,                /* 51 */
  2813. -     nullstr,                /* 52 */
  2814. -     nullstr,                /* 53 */
  2815. -     nullstr,                /* 54 */
  2816. -     nullstr,                /* 55 */
  2817. -     nullstr,                /* 56 */
  2818. -     nullstr,                /* 57 */
  2819. -     nullstr,                /* 58 */
  2820. -     nullstr,                /* 59 */
  2821. -     nullstr,                /* 60 */
  2822. -     nullstr,                /* 61 */
  2823. -     "domain error",                /* 62 */
  2824. -     "range error",                /* 63 */
  2825. -     "range error/bad argument",        /* 64 */
  2826. -     "internal error",            /* 65 */
  2827. -     "bad executable format",        /* 66 */
  2828. -     "memory block growth failure",        /* 67 */
  2829. -     nullstr,                /* 68 */
  2830. -     nullstr,                /* 69 */
  2831. -     nullstr,                /* 70 */
  2832. -     nullstr,                /* 71 */
  2833. -     nullstr,                /* 72 */
  2834. -     nullstr,                /* 73 */
  2835. -     nullstr,                /* 74 */
  2836. -     nullstr,                /* 75 */
  2837. -     nullstr,                /* 76 */
  2838. -     nullstr,                /* 77 */
  2839. -     nullstr,                /* 78 */
  2840. -     nullstr,                /* 79 */
  2841. -     "file already exists",            /* 80 */
  2842. -     "name too long",            /* 81 */
  2843. -     "not a tty",                /* 82 */
  2844. -     };
  2845. - int    sys_nerr = (int)(sizeof(sys_errlist) / sizeof(sys_errlist[0]));
  2846.   void perror(msg)
  2847.       const char *msg;
  2848.       {
  2849. --- 8,13 ----
  2850. ***************
  2851. *** 109,115 ****
  2852.           fputs(msg, stderr);
  2853.           fputs(": ", stderr);
  2854.           }
  2855. !     fputs(strerror(errno), stderr);
  2856.       fputs(".\n", stderr);
  2857.       }
  2858. --- 16,22 ----
  2859.           fputs(msg, stderr);
  2860.           fputs(": ", stderr);
  2861.           }
  2862. !     if(msg = strerror(errno))
  2863. !         fputs(msg, stderr);
  2864.       fputs(".\n", stderr);
  2865.       }
  2866. *** 1.4    1991/04/12 18:19:53
  2867. --- psignal.c    1992/06/03 14:49:24
  2868. ***************
  2869. *** 5,11 ****
  2870.     
  2871.   #include <signal.h>
  2872.   #include <siglist.h>
  2873. - #include <unistd.h>
  2874.   #include <string.h>
  2875.   #include "lib.h"
  2876.     
  2877. --- 5,10 ----
  2878. ***************
  2879. *** 14,27 ****
  2880.       int  sig;
  2881.       const char *prefix;
  2882.   {
  2883. !     write(2, "\r\n", 2);
  2884.       if(prefix && *prefix) {
  2885. !       write(2, prefix, strlen(prefix));
  2886. !       write(2, ": ", 2);
  2887.       }
  2888.       if (sig > 0 && sig < NSIG)
  2889. !       write(2, sys_siglist[sig], (int)strlen(sys_siglist[sig]));
  2890.        else
  2891. !       write(2, "unknown signal", 14);
  2892. !     write(2, "\r\n", 2);
  2893.   }
  2894. --- 13,26 ----
  2895.       int  sig;
  2896.       const char *prefix;
  2897.   {
  2898. !     _write(2, "\r\n", 2L);
  2899.       if(prefix && *prefix) {
  2900. !       _write(2, prefix, (long)strlen(prefix));
  2901. !       _write(2, ": ", 2L);
  2902.       }
  2903.       if (sig > 0 && sig < NSIG)
  2904. !       _write(2, sys_siglist[sig], (long)strlen(sys_siglist[sig]));
  2905.        else
  2906. !       _write(2, "unknown signal", 14L);
  2907. !     _write(2, "\r\n", 2L);
  2908.   }
  2909. *** 1.11    1992/03/06 19:19:47
  2910. --- qsort.c    1992/06/03 14:49:25
  2911. ***************
  2912. *** 50,59 ****
  2913.   #define STACK_NOT_EMPTY \
  2914.       (stack < top)                
  2915.   
  2916. ! static void swap __PROTO((unsigned char *, unsigned char *, size_t));
  2917. ! static void Move __PROTO((unsigned char *, unsigned char *, size_t));
  2918. ! static void insert_sort __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
  2919. ! static void *find_pivot __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
  2920.   
  2921.   /* Discontinue quicksort algorithm when partition gets below this size. */
  2922.   
  2923. --- 50,59 ----
  2924.   #define STACK_NOT_EMPTY \
  2925.       (stack < top)                
  2926.   
  2927. ! INLINE static void swap __PROTO((unsigned char *, unsigned char *, size_t));
  2928. ! INLINE static void Move __PROTO((unsigned char *, unsigned char *, size_t));
  2929. ! INLINE static void insert_sort __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
  2930. ! INLINE static void *find_pivot __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
  2931.   
  2932.   /* Discontinue quicksort algorithm when partition gets below this size. */
  2933.   
  2934. *** 1.6    1992/03/06 19:19:47
  2935. --- random.c    1992/06/03 14:49:25
  2936. ***************
  2937. *** 39,45 ****
  2938.    * zeroeth element of the array is the type of R.N.G. being used (small
  2939.    * integer); the remainder of the array is the state information for the
  2940.    * R.N.G.  Thus, 32 bytes of state information will give 7 longs worth of
  2941. !  * state information, which will allow a degree seven polynomial.  (Note: the 
  2942.    * zeroeth word of state information also has some other information stored
  2943.    * in it -- see setstate() for details).
  2944.    * The random number generation technique is a linear feedback shift register
  2945. --- 39,45 ----
  2946.    * zeroeth element of the array is the type of R.N.G. being used (small
  2947.    * integer); the remainder of the array is the state information for the
  2948.    * R.N.G.  Thus, 32 bytes of state information will give 7 longs worth of
  2949. !  * state information, which will allow a degree seven polynomial.  (Note: the
  2950.    * zeroeth word of state information also has some other information stored
  2951.    * in it -- see setstate() for details).
  2952.    * The random number generation technique is a linear feedback shift register
  2953. ***************
  2954. *** 121,133 ****
  2955.    */
  2956.   
  2957.   static  long        randtbl[ DEG_3 + 1 ]    = { TYPE_3,
  2958. !                 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 
  2959. !                 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 
  2960. !                 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, 
  2961. !                 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 
  2962. !                 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7, 
  2963. !                 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, 
  2964. !                 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 
  2965.                       0xf5ad9d0e, 0x8999220b, 0x27fb47b9 };
  2966.   
  2967.   /*
  2968. --- 121,133 ----
  2969.    */
  2970.   
  2971.   static  long        randtbl[ DEG_3 + 1 ]    = { TYPE_3,
  2972. !                 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342,
  2973. !                 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb,
  2974. !                 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
  2975. !                 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86,
  2976. !                 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7,
  2977. !                 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
  2978. !                 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b,
  2979.                       0xf5ad9d0e, 0x8999220b, 0x27fb47b9 };
  2980.   
  2981.   /*
  2982. ***************
  2983. *** 182,198 ****
  2984.    * values produced by this routine.
  2985.    */
  2986.   
  2987. ! void srandom( x )
  2988.   
  2989. !     unsigned int x;
  2990.   {
  2991. !         register  int        i;
  2992. !     long random(void);
  2993.   
  2994.       if(  rand_type  ==  TYPE_0  )  {
  2995.           state[ 0 ] = x;
  2996.       }
  2997.       else  {
  2998.           state[ 0 ] = x;
  2999.           for( i = 1; i < rand_deg; i++ )  {
  3000.           state[i] = 1103515245*state[i - 1] + 12345;
  3001. --- 182,200 ----
  3002.    * values produced by this routine.
  3003.    */
  3004.   
  3005. ! void            /* ++ERS: Berkeley didn't have this */
  3006. ! srandom( x )
  3007.   
  3008. !     unsigned        x;
  3009.   {
  3010. !         register  int        i, j;
  3011. !     long random();
  3012.   
  3013.       if(  rand_type  ==  TYPE_0  )  {
  3014.           state[ 0 ] = x;
  3015.       }
  3016.       else  {
  3017. +         j = 1;
  3018.           state[ 0 ] = x;
  3019.           for( i = 1; i < rand_deg; i++ )  {
  3020.           state[i] = 1103515245*state[i - 1] + 12345;
  3021. ***************
  3022. *** 221,237 ****
  3023.    * Returns a pointer to the old state.
  3024.    */
  3025.   
  3026. - #if !__STDC__
  3027. -    /* you need an ansi C compatible pre-processor jack! */
  3028. - #else
  3029. - #  define STR(s) # s
  3030. - #  define XSTR(s) STR(s)
  3031. - #endif
  3032.   char  *
  3033.   initstate( seed, arg_state, n )
  3034.   
  3035. !     unsigned int    seed;            /* seed for R. N. G. */
  3036.       char        *arg_state;        /* pointer to state array */
  3037.       int            n;            /* # bytes of state info */
  3038.   {
  3039. --- 223,232 ----
  3040.    * Returns a pointer to the old state.
  3041.    */
  3042.   
  3043.   char  *
  3044.   initstate( seed, arg_state, n )
  3045.   
  3046. !     unsigned        seed;            /* seed for R. N. G. */
  3047.       char        *arg_state;        /* pointer to state array */
  3048.       int            n;            /* # bytes of state info */
  3049.   {
  3050. ***************
  3051. *** 241,252 ****
  3052.       else  state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
  3053.       if(  n  <  BREAK_1  )  {
  3054.           if(  n  <  BREAK_0  )  {
  3055. - /*
  3056.           fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n );
  3057. ! */
  3058. !         fputs( "initstate: not enough state (less than " XSTR(BREAK_0)
  3059. !               " bytes)\nwith which to do jack; ignored.\n", stderr);
  3060. !         return NULL;
  3061.           }
  3062.           rand_type = TYPE_0;
  3063.           rand_deg = DEG_0;
  3064. --- 236,243 ----
  3065.       else  state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
  3066.       if(  n  <  BREAK_1  )  {
  3067.           if(  n  <  BREAK_0  )  {
  3068.           fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n );
  3069. !         return 0;
  3070.           }
  3071.           rand_type = TYPE_0;
  3072.           rand_deg = DEG_0;
  3073. ***************
  3074. *** 324,335 ****
  3075.           break;
  3076.   
  3077.           default:
  3078. - /**
  3079.           fprintf( stderr, "setstate: state info has been munged; not changed.\n" );
  3080. - **/
  3081. -         fputs("setstate: state info has been munged; not changed.\n",
  3082. -               stderr);
  3083. -         
  3084.       }
  3085.       state = &new_state[ 1 ];
  3086.       if(  rand_type  !=  TYPE_0  )  {
  3087. --- 315,321 ----
  3088. ***************
  3089. *** 361,367 ****
  3090.   random()
  3091.   {
  3092.       long        i;
  3093. !     
  3094.       if(  rand_type  ==  TYPE_0  )  {
  3095.           i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff;
  3096.       }
  3097. --- 347,353 ----
  3098.   random()
  3099.   {
  3100.       long        i;
  3101.       if(  rand_type  ==  TYPE_0  )  {
  3102.           i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff;
  3103.       }
  3104. ***************
  3105. *** 378,381 ****
  3106.       }
  3107.       return( i );
  3108.   }
  3109. --- 364,366 ----
  3110. *** 1.11    1992/04/06 19:33:32
  3111. --- sbrk.c    1992/06/03 14:49:26
  3112. ***************
  3113. *** 15,20 ****
  3114. --- 15,26 ----
  3115.      brain damage, even when pointed out to them. sigh!)
  3116.   */
  3117.   
  3118. + /*
  3119. +  * support heat and serve C -- whose author continues to be adamant about
  3120. +  * size_t -- big sigh!
  3121. +  */
  3122. + #include <stddef.h>
  3123.   #include <osbind.h>
  3124.   #include <unistd.h>
  3125.   #include <errno.h>
  3126. ***************
  3127. *** 24,36 ****
  3128.   extern short _split_mem;
  3129.   
  3130.   static void * HeapAlloc( sz )
  3131. ! size_t sz ;
  3132.   {
  3133.       char slush [64];
  3134.       register void *sp;
  3135.       
  3136.       sp = (void *)slush;
  3137. !     sz = (sz + 7) & ~((size_t)7L); /* round up request size next octet */
  3138.   
  3139.       if ( sp < (void *)((char *)_heapbase + sz) )
  3140.       {
  3141. --- 30,42 ----
  3142.   extern short _split_mem;
  3143.   
  3144.   static void * HeapAlloc( sz )
  3145. ! unsigned long sz ;
  3146.   {
  3147.       char slush [64];
  3148.       register void *sp;
  3149.       
  3150.       sp = (void *)slush;
  3151. !     sz = (sz + 7) & ~((unsigned long)7L); /* round up request size next octet */
  3152.   
  3153.       if ( sp < (void *)((char *)_heapbase + sz) )
  3154.       {
  3155. ***************
  3156. *** 43,52 ****
  3157.       return( sp );
  3158.   }
  3159.   
  3160. ! asm(".stabs \"_sbrk\",5,0,0,_lsbrk"); /* dept of clean tricks */
  3161.   
  3162.   /* provided for compilers with sizeof(int) == 2 */
  3163. ! void *lsbrk(long n)
  3164.   {
  3165.     void *rval;
  3166.   
  3167. --- 49,62 ----
  3168.       return( sp );
  3169.   }
  3170.   
  3171. ! #ifndef __GNUC__
  3172. ! asm(".stabs \"_sbrk\",5,0,0,__sbrk"); /* dept of clean tricks */
  3173. ! asm(".stabs \"_lsbrk\",5,0,0,__sbrk"); /* dept of clean tricks */
  3174. ! #endif
  3175.   
  3176.   /* provided for compilers with sizeof(int) == 2 */
  3177. ! void *_sbrk(n)
  3178. ! long n;
  3179.   {
  3180.     void *rval;
  3181.   
  3182. ***************
  3183. *** 64,70 ****
  3184.         if(_split_mem)
  3185.         {  /* now switch over to own heap for further requests, including this one */
  3186.         _split_mem = 0;
  3187. !       return lsbrk(n);
  3188.         }
  3189.         errno = ENOMEM;
  3190.         rval = (void *)(-1L);
  3191. --- 74,80 ----
  3192.         if(_split_mem)
  3193.         {  /* now switch over to own heap for further requests, including this one */
  3194.         _split_mem = 0;
  3195. !       return _sbrk(n);
  3196.         }
  3197.         errno = ENOMEM;
  3198.         rval = (void *)(-1L);
  3199. ***************
  3200. *** 71,73 ****
  3201. --- 81,97 ----
  3202.     }
  3203.     return rval;
  3204.   }
  3205. + #ifndef __GNUC__
  3206. + void *sbrk(x)
  3207. + int x;
  3208. + {
  3209. +     return _sbrk((long)x);
  3210. + }
  3211. + void *lsbrk(x)
  3212. + long x;
  3213. + {
  3214. +     return _sbrk(x);
  3215. + }
  3216. + #endif
  3217. *** 1.8    1991/05/23 14:43:17
  3218. --- setbuf.c    1992/06/03 14:49:26
  3219. ***************
  3220. *** 35,42 ****
  3221.    * should stream be flushed before change?? i think so.
  3222.    *    ++jrb
  3223.    */
  3224. - #define __SRC__
  3225. - #include <unistd.h>
  3226.   
  3227.   void setlinebuf(fp)
  3228.   register FILE *fp;
  3229. --- 35,40 ----
  3230. *** 1.2    1991/04/12 18:19:53
  3231. --- sgtty.c    1992/06/03 14:49:27
  3232. ***************
  3233. *** 3,9 ****
  3234.    */
  3235.   
  3236.   #include <ioctl.h>
  3237. - #include <unistd.h>
  3238.   
  3239.   int
  3240.   stty(fd, _tty)
  3241. --- 3,8 ----
  3242. *** 1.7    1992/03/06 19:19:47
  3243. --- sprintf.c    1992/06/03 14:49:27
  3244. ***************
  3245. *** 1,6 ****
  3246. --- 1,7 ----
  3247.   #include <stdarg.h>
  3248.   #include <stdio.h>
  3249.   #include <limits.h>
  3250. + #include "lib.h"
  3251.   
  3252.   #ifdef __SOZOBON__    /* Electronic brain... */
  3253.   static FILE dummyf =
  3254. *** 1.7    1991/06/23 17:07:09
  3255. --- strchr.c    1992/06/03 14:49:28
  3256. ***************
  3257. *** 5,11 ****
  3258. --- 5,21 ----
  3259.   /*
  3260.    * strchr - find first occurrence of a character in a string
  3261.    */
  3262. + #ifdef __GNUC__
  3263.   asm(".stabs \"_index\",5,0,0,_strchr"); /* dept of clean tricks */
  3264. + #else
  3265. + char *
  3266. + index(s, charwanted)
  3267. +       const char *s;
  3268. +       char charwanted;
  3269. + {
  3270. +       return strchr(s, charwanted);
  3271. + }
  3272. + #endif
  3273.   
  3274.   char *                /* found char, or NULL if none */
  3275.   strchr(s, charwanted)
  3276. *** 1.4    1991/05/23 14:43:17
  3277. --- strerror.c    1992/06/03 14:49:29
  3278. ***************
  3279. *** 1,6 ****
  3280. --- 1,104 ----
  3281.   /* from Henry Spencer's stringlib */
  3282.   #include <string.h>
  3283.   
  3284. + static char nullstr[] = "unknown error";
  3285. + char *sys_errlist[] =
  3286. +     {
  3287. +     "OK",                    /* 0 */
  3288. +     "error",                /* 1 */
  3289. +     "drive not ready",            /* 2 */
  3290. +     "unknown command",            /* 3 */
  3291. +     "crc error",                /* 4 */
  3292. +     "bad request",                /* 5 */
  3293. +     "seek error",                /* 6 */
  3294. +     "unknown media",            /* 7 */
  3295. +     "sector not found",            /* 8 */
  3296. +     "out of paper",                /* 9 */
  3297. +     "write failure",            /* 10 */
  3298. +     "read failure",                /* 11 */
  3299. +     "general mishap",            /* 12 */
  3300. +     "media write protected",        /* 13 */
  3301. +     "media changed",            /* 14 */
  3302. +     "unknown device",            /* 15 */
  3303. +     "bad sectors on format",        /* 16 */
  3304. +     "disk swap request",            /* 17 */
  3305. +     nullstr,                /* 18 */
  3306. +     nullstr,                /* 19 */
  3307. +     nullstr,                /* 20 */
  3308. +     nullstr,                /* 21 */
  3309. +     nullstr,                /* 22 */
  3310. +     nullstr,                /* 23 */
  3311. +     nullstr,                /* 24 */
  3312. +     nullstr,                /* 25 */
  3313. +     nullstr,                /* 26 */
  3314. +     nullstr,                /* 27 */
  3315. +     nullstr,                /* 28 */
  3316. +     nullstr,                /* 29 */
  3317. +     nullstr,                /* 30 */
  3318. +     nullstr,                /* 31 */
  3319. +     "invalid function number",        /* 32 */
  3320. +     "file not found",            /* 33 */
  3321. +     "path not found",            /* 34 */
  3322. +     "no more handles",            /* 35 */
  3323. +     "access denied",            /* 36 */
  3324. +     "invalid handle",            /* 37 */
  3325. +     nullstr,                /* 38 */
  3326. +     "out of memory",            /* 39 */
  3327. +     "invalid memory block",            /* 40 */
  3328. +     nullstr,                /* 41 */
  3329. +     nullstr,                /* 42 */
  3330. +     nullstr,                /* 43 */
  3331. +     nullstr,                /* 44 */
  3332. +     nullstr,                /* 45 */
  3333. +     "invalid drive id",            /* 46 */
  3334. +     nullstr,                /* 47 */
  3335. +     "rename across drives",            /* 48 */
  3336. +     "no more files",            /* 49 */
  3337. +     nullstr,                /* 50 */
  3338. +     nullstr,                /* 51 */
  3339. +     nullstr,                /* 52 */
  3340. +     nullstr,                /* 53 */
  3341. +     nullstr,                /* 54 */
  3342. +     nullstr,                /* 55 */
  3343. +     nullstr,                /* 56 */
  3344. +     nullstr,                /* 57 */
  3345. +     nullstr,                /* 58 */
  3346. +     nullstr,                /* 59 */
  3347. +     nullstr,                /* 60 */
  3348. +     nullstr,                /* 61 */
  3349. +     nullstr,                /* 62 */
  3350. +     nullstr,                /* 63 */
  3351. +     "range error/bad argument",        /* 64 */
  3352. +     "internal error",            /* 65 */
  3353. +     "bad executable format",        /* 66 */
  3354. +     "memory block growth failure",        /* 67 */
  3355. +     nullstr,                /* 68 */
  3356. +     nullstr,                /* 69 */
  3357. +     nullstr,                /* 70 */
  3358. +     nullstr,                /* 71 */
  3359. +     nullstr,                /* 72 */
  3360. +     nullstr,                /* 73 */
  3361. +     nullstr,                /* 74 */
  3362. +     nullstr,                /* 75 */
  3363. +     nullstr,                /* 76 */
  3364. +     nullstr,                /* 77 */
  3365. +     nullstr,                /* 78 */
  3366. +     nullstr,                /* 79 */
  3367. +     "too many symbolic links",        /* 80 */
  3368. +     nullstr,                /* 81 */
  3369. +     nullstr,                /* 82 */
  3370. +     nullstr,                /* 83 */
  3371. +     nullstr,                /* 84 */
  3372. +     "file already exists",            /* 85 */
  3373. +     "name too long",            /* 86 */
  3374. +     "not a tty",                /* 87 */
  3375. +     "range error",                /* 88 */
  3376. +     "domain error"                /* 89 */
  3377. +     };
  3378. + int    sys_nerr = (int)(sizeof(sys_errlist)/sizeof(sys_errlist[0]));
  3379.   /*
  3380.    * strerror - map error number to descriptive string
  3381.    *
  3382. ***************
  3383. *** 16,20 ****
  3384.       if (errnum >= 0 && errnum < sys_nerr)
  3385.           return(sys_errlist[errnum]);
  3386.       else
  3387. !         return("unknown error");
  3388.   }
  3389. --- 114,118 ----
  3390.       if (errnum >= 0 && errnum < sys_nerr)
  3391.           return(sys_errlist[errnum]);
  3392.       else
  3393. !         return(nullstr);
  3394.   }
  3395. *** 1.5    1992/04/13 15:50:45
  3396. --- strftime.c    1992/06/03 14:49:29
  3397. ***************
  3398. *** 196,205 ****
  3399.               strftime(buf, sizeof buf, "%H:%M:%S", ts);
  3400.               break;
  3401.   #endif
  3402. -            default:
  3403. -             buf[0] = q;
  3404. -             buf[1] = 0;
  3405. -             break;
  3406.                   }
  3407.   
  3408.                   if (num + (len = strlen(putstr)) >= maxsize)
  3409. --- 196,201 ----
  3410. *** 1.5    1991/04/12 18:19:53
  3411. --- strlen.c    1992/06/03 14:49:29
  3412. ***************
  3413. *** 13,18 ****
  3414.   
  3415.       if (!scan) return 0;
  3416.       while (*scan++ != '\0')
  3417. !         continue;
  3418.       return (size_t)((long)scan - (long)start);
  3419.   }
  3420. --- 13,18 ----
  3421.   
  3422.       if (!scan) return 0;
  3423.       while (*scan++ != '\0')
  3424. !         continue;
  3425.       return (size_t)((long)scan - (long)start);
  3426.   }
  3427. *** 1.7    1991/06/23 17:07:09
  3428. --- strrchr.c    1992/06/03 14:49:31
  3429. ***************
  3430. *** 4,10 ****
  3431. --- 4,20 ----
  3432.   /*
  3433.    * strrchr - find last occurrence of a character in a string
  3434.    */
  3435. + #ifdef __GNUC__
  3436.   asm(".stabs \"_rindex\",5,0,0,_strrchr"); /* dept of clean tricks */
  3437. + #else
  3438. + char *
  3439. + rindex(s, charwanted)
  3440. +       const char *s;
  3441. +       char charwanted;
  3442. + {
  3443. +       return strrchr(s, charwanted);
  3444. + }
  3445. + #endif
  3446.   
  3447.   char *                /* found char, or NULL if none */
  3448.   strrchr(s, charwanted)
  3449. *** 1.16    1992/04/06 19:33:32
  3450. --- system.c    1992/06/03 14:49:32
  3451. ***************
  3452. *** 3,9 ****
  3453.    *
  3454.    * Written by Eric R. Smith and placed in the public domain.
  3455.    *
  3456. !  * Modified by Allan Pratt to call unx2dos on redirect file names
  3457.    * and to call spawnvp() without calling fork() -- why bother?
  3458.    *
  3459.    * Modified by Frank Ridderbusch in _parseargs() to handle the case
  3460. --- 3,9 ----
  3461.    *
  3462.    * Written by Eric R. Smith and placed in the public domain.
  3463.    *
  3464. !  * Modified by Allan Pratt to call _unx2dos on redirect file names
  3465.    * and to call spawnvp() without calling fork() -- why bother?
  3466.    *
  3467.    * Modified by Frank Ridderbusch in _parseargs() to handle the case
  3468. ***************
  3469. *** 12,18 ****
  3470.    *
  3471.    */
  3472.   
  3473. ! #include <stdio.h>
  3474.   #include <string.h>
  3475.   #include <ctype.h>
  3476.   #include <stdlib.h>
  3477. --- 12,18 ----
  3478.    *
  3479.    */
  3480.   
  3481. ! #include <limits.h>
  3482.   #include <string.h>
  3483.   #include <ctype.h>
  3484.   #include <stdlib.h>
  3485. ***************
  3486. *** 23,34 ****
  3487.   #include <unistd.h>
  3488.   #include "lib.h"
  3489.   
  3490. - #ifndef _COMPILER_H
  3491. - #include <compiler.h>
  3492. - #endif
  3493.   #define isquote(c) ((c) == '\"' || (c) == '\'' || (c) == '`')
  3494. ! #define ARG_ERR       ( (Argentry *) -1L )
  3495.   
  3496.   /* struct. used to build a list of arguments for the command */
  3497.   
  3498. --- 23,30 ----
  3499.   #include <unistd.h>
  3500.   #include "lib.h"
  3501.   
  3502.   #define isquote(c) ((c) == '\"' || (c) == '\'' || (c) == '`')
  3503. ! #define ARG_ERR       ( (Argentry *) -1 )
  3504.   
  3505.   /* struct. used to build a list of arguments for the command */
  3506.   
  3507. ***************
  3508. *** 37,45 ****
  3509.       char    string[1];
  3510.   } Argentry;
  3511.   
  3512. - static Argentry *_argalloc __PROTO((const char *s));
  3513. - static void _argfree __PROTO((Argentry *p));
  3514. - static Argentry *_parseargs __PROTO((const char *s));
  3515.   
  3516.   /* allocate an Argentry that will hold the string "s" */
  3517.   
  3518. --- 33,38 ----
  3519. ***************
  3520. *** 82,92 ****
  3521.       const char *s;
  3522.   {
  3523.       Argentry *cur, *res;
  3524. - #ifdef __SOZOBON__        /* This is actually the legal way, */
  3525.       char buf[1024];
  3526. - #else
  3527. -     char buf[BUFSIZ];    /* because this features a cast. */
  3528. - #endif
  3529.       char *t, quote;
  3530.   
  3531.       res = cur = _argalloc("");
  3532. --- 75,81 ----
  3533. ***************
  3534. *** 136,142 ****
  3535.       char *infile, *outfile;
  3536.       int  infd = 0, outfd = 1, append = 0;
  3537.       int oldin = 0, oldout = 1;    /* hold the Fdup'd in, out */
  3538. !     char path[FILENAME_MAX];
  3539.       int retval;
  3540.   
  3541.       if (!s)        /* check for system() supported ?? */
  3542. --- 125,131 ----
  3543.       char *infile, *outfile;
  3544.       int  infd = 0, outfd = 1, append = 0;
  3545.       int oldin = 0, oldout = 1;    /* hold the Fdup'd in, out */
  3546. !     char path[PATH_MAX];
  3547.       int retval;
  3548.   
  3549.       if (!s)        /* check for system() supported ?? */
  3550. *** 1.4    1991/04/12 18:19:53
  3551. --- time.c    1992/06/03 14:49:33
  3552. ***************
  3553. *** 3,18 ****
  3554.   
  3555.   #include <time.h>
  3556.   #include <osbind.h>
  3557. - #include <unistd.h>
  3558.   
  3559.   static struct tm this_tm;
  3560.   
  3561.   /* unixtime: convert a DOS time/date pair into a unix time */
  3562.   
  3563. ! time_t unixtime(dostime, dosdate)
  3564.       unsigned dostime, dosdate;
  3565.   {
  3566. !     extern time_t mktime(const struct tm *);
  3567.       struct tm *stm = &this_tm;
  3568.   
  3569.       stm->tm_sec = (dostime & 31) << 1;
  3570. --- 3,23 ----
  3571.   
  3572.   #include <time.h>
  3573.   #include <osbind.h>
  3574.   
  3575.   static struct tm this_tm;
  3576. + int _dst;
  3577.   
  3578.   /* unixtime: convert a DOS time/date pair into a unix time */
  3579. + /* in case people were wondering about whether or not DST is applicable
  3580. +  * right now, we set the external variable _dst to the value
  3581. +  * returned from mktime
  3582. +  */
  3583.   
  3584. ! time_t 
  3585. ! _unixtime(dostime, dosdate)
  3586.       unsigned dostime, dosdate;
  3587.   {
  3588. !     time_t t;
  3589.       struct tm *stm = &this_tm;
  3590.   
  3591.       stm->tm_sec = (dostime & 31) << 1;
  3592. ***************
  3593. *** 21,29 ****
  3594.       stm->tm_mday = dosdate & 31;
  3595.       stm->tm_mon = ((dosdate >> 5) & 15) - 1;
  3596.       stm->tm_year = 80 + ((dosdate >> 9) & 255);
  3597.   
  3598. ! /* mktime expects a local time */
  3599. !     return mktime(stm);
  3600.   }
  3601.   
  3602.   time_t time(t)
  3603. --- 26,39 ----
  3604.       stm->tm_mday = dosdate & 31;
  3605.       stm->tm_mon = ((dosdate >> 5) & 15) - 1;
  3606.       stm->tm_year = 80 + ((dosdate >> 9) & 255);
  3607. +     stm->tm_isdst = -1;    /* we don't know about DST */
  3608. +     stm->tm_wday = stm->tm_yday = -1; /* or about these */
  3609.   
  3610. ! /* mktime expects a local time, which is what we're giving it */
  3611. !     t = mktime(stm);
  3612. !     _dst = (stm->tm_isdst == 1) ? 1 : 0;
  3613. !     return t;
  3614.   }
  3615.   
  3616.   time_t time(t)
  3617. ***************
  3618. *** 34,42 ****
  3619.   
  3620.       dostime = Tgettime();
  3621.       dosdate = Tgetdate();
  3622. !     made = unixtime(dostime, dosdate);
  3623.       if (t)
  3624.           *t = made;
  3625.       return made;
  3626.   }
  3627. --- 44,51 ----
  3628.   
  3629.       dostime = Tgettime();
  3630.       dosdate = Tgetdate();
  3631. !     made = _unixtime(dostime, dosdate);
  3632.       if (t)
  3633.           *t = made;
  3634.       return made;
  3635.   }
  3636. *** 1.2    1989/07/17 02:24:36
  3637. --- tmpfile.c    1992/06/03 14:49:33
  3638. ***************
  3639. *** 6,11 ****
  3640. --- 6,13 ----
  3641.   #include <stdio.h>
  3642.   #include <stdlib.h>
  3643.   
  3644. + extern int __mint;
  3645.   typedef struct {
  3646.       char    *name;
  3647.       FILE    *fp;
  3648. ***************
  3649. *** 37,42 ****
  3650. --- 39,54 ----
  3651.               free(junknam);
  3652.           return NULL;
  3653.       }
  3654. + /* in MiNT 0.9 and above, we can often unlink a file and continue to use
  3655. +  * it; some file systems may return EACCDN for unlinking an open file,
  3656. +  * in which case we use the old method of unlinking the file at exit
  3657. +  */
  3658. +     if (__mint >= 9) {
  3659. +         if (remove(junknam) == 0)
  3660. +             return junkfil;
  3661. +     }
  3662.       if((++numtmps) == 0)
  3663.           file_to_delete = (FILE_RECORD *)malloc((size_t)sizeof(FILE_RECORD));
  3664.       else
  3665. *** 1.7    1992/03/06 19:19:47
  3666. --- tmpnam.c    1992/06/03 14:49:34
  3667. ***************
  3668. *** 1,27 ****
  3669.   /* tmpnam.c : return a temporary file name */
  3670.   /* written by Eric R. Smith and placed in the public domain */
  3671.   #include <stdio.h>
  3672.   #include <stdlib.h>
  3673.   #include <string.h>
  3674.   
  3675. ! extern char *getenv(const char *), *mktemp(char *), *strcpy(char *, const char *),
  3676. !  *strcat(char *, const char *);
  3677.   
  3678.   char *tmpnam(buf)
  3679.       char *buf;
  3680.   {
  3681.       char *tmpdir;
  3682. !     if (!buf && !(buf = (char *)malloc(L_tmpnam)))
  3683. !         return NULL;
  3684.   
  3685. !     if (!(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMPDIR")))
  3686. ! #ifdef UNIX
  3687. !         tmpdir = "/tmp";
  3688. ! #else
  3689.           tmpdir = ".";
  3690. ! #endif
  3691. !     (void) strcat(strcpy(buf, tmpdir), "\\__XXXXXX");
  3692.       return(mktemp(buf));
  3693.   }
  3694. --- 1,40 ----
  3695.   /* tmpnam.c : return a temporary file name */
  3696.   /* written by Eric R. Smith and placed in the public domain */
  3697. ! /**
  3698. !  *  - retuned name can be passed outside via system(); other programs
  3699. !  *    may not dig '/' as a path separator
  3700. !  *  - somehow more frugal in a memory use
  3701. !  *    (mj - October 1990)
  3702. !  **/
  3703.   #include <stdio.h>
  3704.   #include <stdlib.h>
  3705.   #include <string.h>
  3706.   
  3707. ! static char pattern[] = "\\__XXXXXX";
  3708.   
  3709.   char *tmpnam(buf)
  3710.       char *buf;
  3711.   {
  3712.       char *tmpdir;
  3713. !     size_t tlen;
  3714. !     extern char *mktemp __PROTO((char *));
  3715.   
  3716. !     if (!(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMPDIR")) &&
  3717. !         !(tmpdir = getenv("TMP")) && !(tmpdir = getenv("TEMPDIR")))
  3718.           tmpdir = ".";
  3719. !     tlen = strlen(tmpdir);
  3720. !     if (!buf) {
  3721. !         size_t blen;
  3722. !         
  3723. !         blen = tlen + sizeof(pattern);
  3724. !         if (NULL == (buf = (char *) malloc(blen)))
  3725. !             return NULL;
  3726. !     }
  3727. !     strcpy(buf, tmpdir);
  3728. !     if (tmpdir[tlen-1] == '/' || tmpdir[tlen-1] == '\\')
  3729. !         --tlen;
  3730. !     strcpy(buf+tlen, pattern);
  3731.       return(mktemp(buf));
  3732.   }
  3733. *** 1.8    1991/06/11 23:04:27
  3734. --- utime.c    1992/06/03 14:49:34
  3735. ***************
  3736. *** 11,19 ****
  3737.    *
  3738.    */
  3739.   
  3740. ! #include <stdio.h>
  3741. ! #include <unistd.h>
  3742. ! #include <support.h>
  3743.   #include <errno.h>
  3744.   #include <osbind.h>
  3745.   #include <assert.h>
  3746. --- 11,19 ----
  3747.    *
  3748.    */
  3749.   
  3750. ! #include <limits.h>
  3751. ! #include <sys/types.h>
  3752. ! #include <time.h>
  3753.   #include <errno.h>
  3754.   #include <osbind.h>
  3755.   #include <assert.h>
  3756. ***************
  3757. *** 25,31 ****
  3758.   time_t dostime(t)
  3759.       time_t t;
  3760.   {
  3761. !       time_t time, date;
  3762.       struct tm *ctm;
  3763.   
  3764.       if (!(ctm = localtime(&t)))
  3765. --- 25,31 ----
  3766.   time_t dostime(t)
  3767.       time_t t;
  3768.   {
  3769. !         time_t time, date;
  3770.       struct tm *ctm;
  3771.   
  3772.       if (!(ctm = localtime(&t)))
  3773. ***************
  3774. *** 44,50 ****
  3775.       int fh;
  3776.       time_t settime;
  3777.       unsigned long dtime;    /* dos time equivalent */
  3778. !     char filename[FILENAME_MAX];
  3779.   
  3780.       if (tset)
  3781.           settime = tset->modtime;
  3782. --- 44,50 ----
  3783.       int fh;
  3784.       time_t settime;
  3785.       unsigned long dtime;    /* dos time equivalent */
  3786. !     char filename[PATH_MAX];
  3787.   
  3788.       if (tset)
  3789.           settime = tset->modtime;
  3790.